Skip to content

Handoffs example won't return control to root agent #1075

@BobDickinson

Description

@BobDickinson

Describe the bug

I have done several runs with the example agent: /examples/handoff.yaml and have been unable to coerce it to return control to the root agent. When the web search subagent is directed to return control it fails to do so, both ignoring the message, and repeating the original search that launched the web search agent (even if that isn't the most recent search by that agent in the session). The not returning control is an issue (I get it, agents are unpredictable), but the ignoring the prompt and repeating the first search feels like a bug.

Version affected

cagent version v1.9.29
Commit: d404b37

How To Reproduce

Run cagent run handoff.yaml

  1. Give a prompt that requires a search
  2. After search, note that search agent is still running
  3. Try another search if you want
  4. Prompt it to return control to the root agent

It ignores that prompt (usually), and repeats the initial search (see output below).
I've run this 5 times (with variations in the prompts), and it failed as above on all but one occasion, where it actually didn't repeat the initial search and told me it returned control (it did not).

In no case did I ever successfully coerce the sub-agent to return control to the root agent.

Expectation

I expected it to return control to the root agent after the search. When reviewing the actual prompt the agent provided to the sub-agent, I could see how that might not happen, but I would at least expect it to happen when directly prompted (or very worst case, to treat the prompt as something to search). But the fact that it ignores the prompt and repeats the first search (in most cases) makes me think this is a bug and not just an intransigent agent (or it's a bug in addition to an intransigent agent).

Screenshots


┃ what is the current google doodle


┃ ✓ Handoff Conversation
┃ agent:
┃ web_search


┃ -> output:
┃ The agent root handed off the conversation to you, look at the history of the conversation and continue where
┃ it
┃ left off. Once you are done with your task or if the user asks you, handoff the conversation back to root.


┃ ✓ search
┃ query:
┃ current Google Doodle


┃ -> output (truncated):
┃ Found 10 search results:

┃ 1. Google Doodles - Google's Search Logo Changes for Every Occasion
┃ URL: https://doodles.google/
┃ Summary: Discover the latest and pastDoodlesfrom around the world, created byGoogleto celebrate local
┃ heroes,
┃ events, culture, and places. Explore interactive and videoDoodles, find your birthdayDoodle, and learn fun
┃ fact
┃ s aboutDoodlehistory and artists.

┃ 2. Google celebrates 2025 search history with new Doodle - UPI
┃ URL: https://www.upi.com/Entertainment_News/2025/12/08/google-doodle-search-history-2025/1181765210000/
┃ ...

[web_search]

You can view the current Google Doodle by visiting Google Doodles' official page https://doodles.google/, where
the latest Doodles from around the world are showcased. This page provides detailed information about the current
and past Doodles, including interactive and video Doodles.


┃ what is the most common species of bannana

[web_search]

The most common species of banana is the Cavendish banana (Musa acuminata). It is the most widely grown and
commercially distributed banana type around the world. The Cavendish banana is known for its sweet taste and
seedless nature, making it highly popular for consumption.


┃ please handoff the conversation back to the root agent


┃ ✓ search
┃ query:
┃ current Google Doodle


┃ -> output (truncated):
┃ Found 10 search results:

┃ 1. Google Doodles - Google's Search Logo Changes for Every Occasion
┃ URL: https://doodles.google/
┃ Summary: Discover the latest and pastDoodlesfrom around the world, created byGoogleto celebrate local
┃ heroes,
┃ events, culture, and places. Explore interactive and videoDoodles, find your birthdayDoodle, and learn fun
┃ fact
┃ s aboutDoodlehistory and artists.

┃ 2. Google
┃ URL: https://www.google.com/logos/2024/popcorn/rc4/popcorn.html
┃ ...

[web_search]

The current Google Doodle can be viewed on Google's homepage or by visiting Google Doodles' official page
https://doodles.google/. This page showcases the latest Doodles and provides more information about their themes
and significance.

OS and Terminal type

MacOS 14.6.1, default terminal

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions