View as Markdown

Accept a sub-agent#

An agent hands a sub-agent part of its approval, never more, and it ends when the person withdraws the first.

Level 1: A person approves with a passkey.
Class read: Nothing changes. The approval can be reused until it ends or the person withdraws it.
routes.append(route("GET", "/notes/{id}/summary", "notes:read", level=1, resource="note:{id}",
                    summary="Summarise one note"))


@app.get("/notes/<note_id>/summary")
def summarise(note_id):
    # An agent may hand a sub-agent part of its approval: the SDK checks the chain, and human_id is the same.
    note = notes.get(g.allowedby.human_id, note_id)
    if not note:
        return {"error": "no such note"}, 404
    return {"words": len(note["text"].split()), "delegated": len(g.allowedby.chain) > 1}

Run in 8 languages on this version. See the results

What the test proves#

  • the sub-agent reads the one note it was given, for the same person; nobody is asked
  • every note is out of its reach, and more than the agent has cannot be handed on
  • the chain works with the sub-agent's key only
  • the person withdraws the agent's approval: the sub-agent's ends with it