Skip to content

[Bug] AG-UI interface tools are not integrated with the Agent #7801

@MalaikaAbb

Description

@MalaikaAbb

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

  1. Go to CopilotKit Quickstart for Agno and setup your agent using 'Use an Existing Agent' Method
  2. Set up the backend, and frontend following the guide above.
  3. In the Generative UI Section -> Go to Your Components Sections (Display-Only + Interactive) - Neither of these work.
  4. 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

Image
  • 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

Image
Image

Actual Behavior

Tools are not triggered at all. Following responses are given by the agent

  1. useComponent Hook
Image
  1. useHumanInTheLoop Hook
Image
  • Furthermore, when debuging, we intercepted the HTTP request from AG-UI and extracted the tools attached to it
Image

In our Agent, we set debug_mode=True, and checked the tools which were registered with the Agent. (Above are not included)

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions