Skip to content

enhancement(agent): add returnRunResult option to agent.asTool() to expose RunResult and interruptions #249

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vrtnis
Copy link
Contributor

@vrtnis vrtnis commented Jul 23, 2025

This adds a returnRunResult option to agent.asTool() that allows developers to access the full RunResult of the sub-agent when invoked as a tool.

By default, asTool() only returns the final output string of the sub-agent, which means any interruptions (e.g. approval requests via needsApproval) are hidden from the parent agent.

With this flag enabled:

  • The full RunResult is returned
  • Interruptions are visible to the outer agent
  • Human-in-the-loop and nested approval workflows now work as expected

This change is backward-compatible and opt-in. It does not affect any existing users of asTool().

Example usage:

agentB.asTool({
  toolName: 'agentB',
  returnRunResult: true,
});

Resolves #243

Copy link

changeset-bot bot commented Jul 23, 2025

🦋 Changeset detected

Latest commit: ca0595f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@openai/agents-core Patch
@openai/agents-openai Patch
@openai/agents-realtime Patch
@openai/agents Patch
@openai/agents-extensions Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working package:agents-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Agent that has Agent asTool that has Tool that needsApproval does not return interruptions
2 participants