agents
agents copied to clipboard
Passing parameters and persisting private/backend state in the agent DO
While playing with the agents SDK, the one big missing thing for me is a way to pass parameters when initializing an agent for a route, and storing/persisting backend state without sharing it with the clients.
For example, let's imagine that I'm building a "GitHub + AI" service and I want one agent per repository, I could have a route /repo/:org/:id/agent to access the agent, but I need to check permissions before connecting to the agent and then passorg and id to the agent.
I'd love an API where I could pass an object instead of an ID to getAgentByName:
const agent = await getAgentByName<Env, AgentCodeRepo>(
this.env.AGENT,
{
orgId,
repoId,
}
);
and then access it from within the agent:
this.params.orgId
On top of all of this, it'd be amazing to have a way to get/update a private state. Right now the only solution is to implement something similar to setState using the SQL storage, but without the broadcasting to the clients.