-
Notifications
You must be signed in to change notification settings - Fork 442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AgentNetwork (Experimental) #2744
base: main
Are you sure you want to change the base?
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 Documentation updates detected! You can review documentation updates here |
// const { memory } = useMemory(networkId!); | ||
// const navigate = useNavigate(); | ||
const { messages, isLoading: isMessagesLoading } = useMessages({ | ||
agentId: networkId!, | ||
threadId: threadId!, | ||
memory: false, | ||
}); | ||
|
||
// const [sidebar, setSidebar] = useState(true); | ||
// const { | ||
// threads, | ||
// isLoading: isThreadsLoading, | ||
// mutate: refreshThreads, | ||
// } = useThreads({ resourceid: networkId!, agentId: networkId!, isMemoryEnabled: !!memory?.result }); | ||
|
||
// useEffect(() => { | ||
// if (memory?.result && !threadId) { | ||
// // use @lukeed/uuid because we don't need a cryptographically secure uuid (this is a debugging local uuid) | ||
// // using crypto.randomUUID() on a domain without https (ex a local domain like local.lan:4111) will cause a TypeError | ||
// navigate(`/networks/${networkId}/chat/${uuid()}`); | ||
// } | ||
// }, [memory?.result, threadId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this commented code? Should it be uncommented or deleted?
{/* {sidebar && memory?.result ? ( | ||
<div className="border-r"> | ||
<div className="p-4"> | ||
<h3 className="text-sm font-medium text-mastra-el-5 mb-2">Network Conversations</h3> | ||
{isThreadsLoading ? ( | ||
<p className="text-sm text-mastra-el-4">Loading threads...</p> | ||
) : threads.length === 0 ? ( | ||
<p className="text-sm text-mastra-el-4">No conversations yet</p> | ||
) : ( | ||
<div className="space-y-2"> | ||
{threads.map((thread) => ( | ||
<div | ||
key={thread.id} | ||
className={`p-2 rounded-md cursor-pointer text-sm ${thread.id === threadId ? 'bg-mastra-bg-3 text-mastra-el-5' : 'hover:bg-mastra-bg-2 text-mastra-el-4'}`} | ||
onClick={() => navigate(`/networks/${networkId}/chat/${thread.id}`)} | ||
> | ||
{thread.name || 'Conversation'} | ||
</div> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
) : null} */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
type AgentTool = ReturnType<typeof createTool>; | ||
|
||
// Create tools from agents with state tracking | ||
const agentAsTools = this.agents.reduce<Record<string, AgentTool>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought for a later day: during the demo earlier the multi-step agent calling was a little slow and it just occured to me we could give the router agent a parallel agent tool so it could message multiple agents, they could generate at the same time, and it could get the result back. ex input args where each key is the name of an agent and the value is the message to send.
{ agentA: "do x", agentB: "do y" }
Res would match:
{ agentA: "As a large language model...", agentB: "lol" }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice thing is this could be a single tool then. The router could choose to call one or more agents with it
|
||
const result = await agent.generate(agentContext, { | ||
context: this.current_state?.lastResult | ||
? [{ role: 'assistant', content: this.current_state?.lastResult }] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not important for this PR but we could use memory for this
getNetworkState: createTool({ | ||
id: 'getNetworkState', | ||
description: 'Get the current state of the agent network, including previous agent results and call history', | ||
inputSchema: z.object({}), | ||
outputSchema: z.object({ | ||
state: z.object({ | ||
callCount: z.number(), | ||
lastResult: z.any(), | ||
input: z.string(), | ||
agentResults: z.record(z.string()), | ||
agentHistory: z.array( | ||
z.object({ | ||
agent: z.string(), | ||
input: z.string(), | ||
result: z.string(), | ||
timestamp: z.string(), | ||
}), | ||
), | ||
stateData: z.record(z.unknown()), | ||
}), | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it could use a huge amount of tokens - isn't this covered by the agent tool responses in each agent tool call? Since the tool call args and results will be in context for the router agent
Vibe coded this! It works mediocrely. Will have to make it better