Documentation
¶
Overview ¶
This sample demonstrates a sub-agent that runs in another process. An orchestrator delegates research to a researcher agent that a second Genkit app (./researcher) serves over HTTP, and the delegation works the way it does for an agent in the same process, background tasks included.
The researcher is an ordinary Genkit app serving an agent. This program registers it with genkitx.DefineRemoteAgent and gives it to the agents middleware by name, exactly as it would a local agent.
Run it from this directory (the Google AI plugin reads GEMINI_API_KEY). It starts the researcher on 127.0.0.1:8081 and serves the orchestrator on 127.0.0.1:8080:
go run .
Chat with the orchestrator in the Dev UI, and read the trace of every delegation at http://localhost:4000/traces:
genkit start -- go run .
Or over HTTP, streaming the turn:
curl -N -X POST 'http://localhost:8080/agents/orchestrator?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"message": {"role": "user", "content": [{"text": "Compare the history of Tokyo and Kyoto as capitals of Japan."}]}}}'
The orchestrator starts one researcher task per part of the question in the background, waits for them, and combines the answers.
Directories
¶
| Path | Synopsis |
|---|---|
|
Command researcher serves the researcher agent of the basic-agents-remote sample on 127.0.0.1:8081.
|
Command researcher serves the researcher agent of the basic-agents-remote sample on 127.0.0.1:8081. |