Description
HTTP request coming from AG-UI Interface contains frontend tools declared using CopilotKit packages. However, the agent is not recognizing them since run_agent does not extract tools from incoming HTTP request
|
async def run_agent(agent: Union[Agent, RemoteAgent], run_input: RunAgentInput) -> AsyncIterator[BaseEvent]: |
|
"""Run the contextual Agent, mapping AG-UI input messages to Agno format, and streaming the response in AG-UI format.""" |
|
run_id = run_input.run_id or str(uuid.uuid4()) |
|
|
|
try: |
|
# AG-UI frontends send full conversation history every request. |
|
# Extract only the last user message — agent manages history via session DB. |
|
user_input = extract_agui_user_input(run_input.messages or []) |
|
|
|
yield RunStartedEvent(type=EventType.RUN_STARTED, thread_id=run_input.thread_id, run_id=run_id) |
|
|
|
# Look for user_id in run_input.forwarded_props |
|
user_id = None |
|
if run_input.forwarded_props and isinstance(run_input.forwarded_props, dict): |
|
user_id = run_input.forwarded_props.get("user_id") |
|
|
|
# Validating the session state is of the expected type (dict) |
|
session_state = validate_agui_state(run_input.state, run_input.thread_id) |
|
|
|
# Request streaming response from agent |
|
response_stream = agent.arun( # type: ignore |
|
input=user_input, |
|
session_id=run_input.thread_id, |
|
stream=True, |
|
stream_events=True, |
|
user_id=user_id, |
|
session_state=session_state, |
|
run_id=run_id, |
|
) |
Hence, during run, only the tools registered with agent are considered, the AGUI tools are bypassed since they are never accessed in the first place.
Steps to Reproduce
- Go to CopilotKit Quickstart for Agno and setup your agent using 'Use an Existing Agent' Method
- Set up the backend, and frontend following the guide above.
- In the Generative UI Section -> Go to Your Components Sections (Display-Only + Interactive) - Neither of these work.
- AG-UI Inspector can be checked to validate no tool call was invoked.
Agent Configuration (if applicable)
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.os.interfaces.agui import AGUI
agent = Agent(
model=OpenAIChat(id="gpt-5.4"),
description="A helpful assistant that can answer questions and provide information.",
instructions="Be helpful and friendly. Format your responses using markdown where appropriate.",
)
agent_os = AgentOS(agents=[agent], interfaces=[AGUI(agent=agent)])
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="main:app", port=8000, reload=True)
Expected Behavior
- When using useComponent hook from copilotkit/react-core/v2, a card should be rendered in the following format
CODE being used in frontend
import { useComponent } from "@copilotkit/react-core/v2";
const weatherSchema = z.object({
city: z.string().describe("City name"),
temperature: z.number().describe("Temperature in Fahrenheit"),
condition: z.string().describe("Weather condition"),
});
function WeatherCard({ city, temperature, condition }: z.infer<typeof weatherSchema>) {
return (
<div className="rounded-lg border p-4">
<h3 className="font-semibold">{city}</h3>
<p className="text-2xl">{temperature}°F</p>
<p className="text-sm text-gray-500">{condition}</p>
</div>
);
}
useComponent({
name: "showWeather",
description: "Display a weather card for a city.",
parameters: weatherSchema,
render: WeatherCard,
});
EXPECTED RESULT
- When using useHumanInTheLoop hook from copilotkit/react-core/v2, it should render Approve/Deny buttons
CODE Being used
useHumanInTheLoop({
name: "humanApprovedCommand",
description: "Ask human for approval to run a command.",
parameters: z.object({ command: z.string().describe("The command to run") }),
render: ({ args, respond, status }) => {
if (status !== "executing") return <></>;
return (
<div>
<pre>{args.command}</pre>
<button onClick={() => respond?.(`Tell the user the command ran`)}>Approve</button>
<button onClick={() => respond?.(`Tell the user the command wasn't run`)}>Deny</button>
</div>
);
},
});
EXPECTED RESULTS
Actual Behavior
Tools are not triggered at all. Following responses are given by the agent
- useComponent Hook
- useHumanInTheLoop Hook
- Furthermore, when debuging, we intercepted the HTTP request from AG-UI and extracted the tools attached to it
In our Agent, we set debug_mode=True, and checked the tools which were registered with the Agent. (Above are not included)
Screenshots or Logs (if applicable)
No response
Environment
- Linux Ubuntu LTS 24.04
- "@ag-ui/agno": "^0.0.3",
"@copilotkit/react-core": "^1.56.5",
"@copilotkit/react-ui": "^1.56.5",
"@copilotkit/runtime": "^1.56.5",
- Agno version 2.6.4
Possible Solutions (optional)
Solution: Extract the tools from AG-UI request body and merge them with the agent
Additional Context
No response
Description
HTTP request coming from AG-UI Interface contains frontend tools declared using CopilotKit packages. However, the agent is not recognizing them since run_agent does not extract tools from incoming HTTP request
agno/libs/agno/agno/os/interfaces/agui/router.py
Lines 33 to 61 in 85e7c0d
Hence, during run, only the tools registered with agent are considered, the AGUI tools are bypassed since they are never accessed in the first place.
Steps to Reproduce
Agent Configuration (if applicable)
Expected Behavior
CODE being used in frontend
EXPECTED RESULT
CODE Being used
EXPECTED RESULTS
Actual Behavior
Tools are not triggered at all. Following responses are given by the agent
In our Agent, we set debug_mode=True, and checked the tools which were registered with the Agent. (Above are not included)
Screenshots or Logs (if applicable)
No response
Environment
Possible Solutions (optional)
Solution: Extract the tools from AG-UI request body and merge them with the agent
Additional Context
No response