Skip to content

Commit c78e806

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/v1.5-upgrade
2 parents 4c19e5d + d4730f7 commit c78e806

File tree

2 files changed

+110
-65
lines changed

2 files changed

+110
-65
lines changed

apps/dojo/src/agents.ts

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import { ADKAgent } from "@ag-ui/adk";
1919
import { SpringAiAgent } from "@ag-ui/spring-ai";
2020
import { HttpAgent } from "@ag-ui/client";
2121
import { A2AMiddlewareAgent } from "@ag-ui/a2a-middleware";
22-
import { A2AAgent } from "@ag-ui/a2a";
23-
import { A2AClient } from "@a2a-js/sdk/client";
22+
// import { A2AAgent } from "@ag-ui/a2a";
23+
// import { A2AClient } from "@a2a-js/sdk/client";
2424

2525
const envVars = getEnvVars();
2626
export const agentsIntegrations: AgentIntegrationConfig[] = [
@@ -118,24 +118,24 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
118118
};
119119
},
120120
},
121-
{
122-
id: "mastra",
123-
agents: async () => {
124-
const mastraClient = new MastraClient({
125-
baseUrl: envVars.mastraUrl,
126-
});
121+
// {
122+
// id: "mastra",
123+
// agents: async () => {
124+
// const mastraClient = new MastraClient({
125+
// baseUrl: envVars.mastraUrl,
126+
// });
127127

128-
return MastraAgent.getRemoteAgents({
129-
mastraClient,
130-
});
131-
},
132-
},
133-
{
134-
id: "mastra-agent-local",
135-
agents: async () => {
136-
return MastraAgent.getLocalAgents({ mastra });
137-
},
138-
},
128+
// return MastraAgent.getRemoteAgents({
129+
// mastraClient,
130+
// });
131+
// },
132+
// },
133+
// {
134+
// id: "mastra-agent-local",
135+
// agents: async () => {
136+
// return MastraAgent.getLocalAgents({ mastra });
137+
// },
138+
// },
139139
{
140140
id: "vercel-ai-sdk",
141141
agents: async () => {
@@ -344,51 +344,51 @@ export const agentsIntegrations: AgentIntegrationConfig[] = [
344344
};
345345
},
346346
},
347-
{
348-
id: "a2a-basic",
349-
agents: async () => {
350-
const a2aClient = new A2AClient(envVars.a2aUrl);
351-
return {
352-
agentic_chat: new A2AAgent({
353-
description: "Direct A2A agent",
354-
a2aClient,
355-
debug: process.env.NODE_ENV !== "production",
356-
}),
357-
};
358-
},
359-
},
360-
{
361-
id: "a2a",
362-
agents: async () => {
363-
// A2A agents: building management, finance, it agents
364-
const agentUrls = [
365-
envVars.a2aMiddlewareBuildingsManagementUrl,
366-
envVars.a2aMiddlewareFinanceUrl,
367-
envVars.a2aMiddlewareItUrl,
368-
];
369-
// AGUI orchestration/routing agent
370-
const orchestrationAgent = new HttpAgent({
371-
url: envVars.a2aMiddlewareOrchestratorUrl,
372-
});
373-
return {
374-
a2a_chat: new A2AMiddlewareAgent({
375-
description: "Middleware that connects to remote A2A agents",
376-
agentUrls,
377-
orchestrationAgent,
378-
instructions: `
379-
You are an HR agent. You are responsible for hiring employees and other typical HR tasks.
347+
// {
348+
// id: "a2a-basic",
349+
// agents: async () => {
350+
// const a2aClient = new A2AClient(envVars.a2aUrl);
351+
// return {
352+
// agentic_chat: new A2AAgent({
353+
// description: "Direct A2A agent",
354+
// a2aClient,
355+
// debug: process.env.NODE_ENV !== "production",
356+
// }),
357+
// };
358+
// },
359+
// },
360+
// {
361+
// id: "a2a",
362+
// agents: async () => {
363+
// // A2A agents: building management, finance, it agents
364+
// const agentUrls = [
365+
// envVars.a2aMiddlewareBuildingsManagementUrl,
366+
// envVars.a2aMiddlewareFinanceUrl,
367+
// envVars.a2aMiddlewareItUrl,
368+
// ];
369+
// // AGUI orchestration/routing agent
370+
// const orchestrationAgent = new HttpAgent({
371+
// url: envVars.a2aMiddlewareOrchestratorUrl,
372+
// });
373+
// return {
374+
// a2a_chat: new A2AMiddlewareAgent({
375+
// description: "Middleware that connects to remote A2A agents",
376+
// agentUrls,
377+
// orchestrationAgent,
378+
// instructions: `
379+
// You are an HR agent. You are responsible for hiring employees and other typical HR tasks.
380380

381-
It's very important to contact all the departments necessary to complete the task.
382-
For example, to hire an employee, you must contact all 3 departments: Finance, IT and Buildings Management. Help the Buildings Management department to find a table.
381+
// It's very important to contact all the departments necessary to complete the task.
382+
// For example, to hire an employee, you must contact all 3 departments: Finance, IT and Buildings Management. Help the Buildings Management department to find a table.
383383

384-
You can make tool calls on behalf of other agents.
385-
DO NOT FORGET TO COMMUNICATE BACK TO THE RELEVANT AGENT IF MAKING A TOOL CALL ON BEHALF OF ANOTHER AGENT!!!
384+
// You can make tool calls on behalf of other agents.
385+
// DO NOT FORGET TO COMMUNICATE BACK TO THE RELEVANT AGENT IF MAKING A TOOL CALL ON BEHALF OF ANOTHER AGENT!!!
386386

387-
When choosing a seat with the buildings management agent, You MUST use the \`pickTable\` tool to have the user pick a seat.
388-
The buildings management agent will then use the \`pickSeat\` tool to pick a seat.
389-
`,
390-
}),
391-
};
392-
},
393-
},
387+
// When choosing a seat with the buildings management agent, You MUST use the \`pickTable\` tool to have the user pick a seat.
388+
// The buildings management agent will then use the \`pickSeat\` tool to pick a seat.
389+
// `,
390+
// }),
391+
// };
392+
// },
393+
// },
394394
];

integrations/langgraph/python/ag_ui_langgraph/agent.py

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from langgraph.graph.state import CompiledStateGraph
77

88
try:
9-
from langchain.schema import BaseMessage, SystemMessage
9+
from langchain.schema import BaseMessage, SystemMessage, ToolMessage
1010
except ImportError:
1111
# Langchain >= 1.0.0
12-
from langchain_core.messages import BaseMessage, SystemMessage
12+
from langchain_core.messages import BaseMessage, SystemMessage, ToolMessage
1313

1414
from langchain_core.runnables import RunnableConfig, ensure_config
1515
from langchain_core.messages import HumanMessage
@@ -682,6 +682,51 @@ async def _handle_single_event(self, event: Any, state: State) -> AsyncGenerator
682682

683683
elif event_type == LangGraphEventTypes.OnToolEnd:
684684
tool_call_output = event["data"]["output"]
685+
686+
if isinstance(tool_call_output, Command):
687+
# Extract ToolMessages from Command.update
688+
messages = tool_call_output.update.get('messages', [])
689+
tool_messages = [m for m in messages if isinstance(m, ToolMessage)]
690+
691+
# Process each tool message
692+
for tool_msg in tool_messages:
693+
if not self.active_run["has_function_streaming"]:
694+
yield self._dispatch_event(
695+
ToolCallStartEvent(
696+
type=EventType.TOOL_CALL_START,
697+
tool_call_id=tool_msg.tool_call_id,
698+
tool_call_name=tool_msg.name,
699+
parent_message_id=tool_msg.id,
700+
raw_event=event,
701+
)
702+
)
703+
yield self._dispatch_event(
704+
ToolCallArgsEvent(
705+
type=EventType.TOOL_CALL_ARGS,
706+
tool_call_id=tool_msg.tool_call_id,
707+
delta=json.dumps(event["data"].get("input", {})),
708+
raw_event=event
709+
)
710+
)
711+
yield self._dispatch_event(
712+
ToolCallEndEvent(
713+
type=EventType.TOOL_CALL_END,
714+
tool_call_id=tool_msg.tool_call_id,
715+
raw_event=event
716+
)
717+
)
718+
719+
yield self._dispatch_event(
720+
ToolCallResultEvent(
721+
type=EventType.TOOL_CALL_RESULT,
722+
tool_call_id=tool_msg.tool_call_id,
723+
message_id=str(uuid.uuid4()),
724+
content=tool_msg.content,
725+
role="tool"
726+
)
727+
)
728+
return
729+
685730
if not self.active_run["has_function_streaming"]:
686731
yield self._dispatch_event(
687732
ToolCallStartEvent(

0 commit comments

Comments
 (0)