Skip to content
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

Make the reset behavior on tool use configurable #335

Merged
merged 1 commit into from
Mar 25, 2025
Merged

Conversation

rm-openai
Copy link
Collaborator

Summary:

#263 added this behavior. The goal was to prevent infinite loops when tool choice was set. The key change I'm making is:

  1. Making it configurable on the agent.
  2. Doing bookkeeping in the Runner to track this, to prevent mutating agents.
  3. Not resetting the global tool choice in RunConfig.

Test Plan:

Unit tests.
.

@rm-openai rm-openai requested a review from stevenheidel March 25, 2025 16:47
stevenheidel
stevenheidel previously approved these changes Mar 25, 2025
@@ -77,6 +77,22 @@ class QueueCompleteSentinel:
_NOT_FINAL_OUTPUT = ToolsToFinalOutputResult(is_final_output=False, final_output=None)


@dataclass
class AgentToolUseTracker:
data: list[tuple[Agent, list[str]]] = field(default_factory=list)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better name than data? i couldn't figure out what this is

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will rename

@@ -208,8 +208,10 @@ async def _fetch_response(
list_input = ItemHelpers.input_to_new_input_list(input)

parallel_tool_calls = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be easier to read as an if/elif/else block rather than this expression

## Summary:

#263 added this behavior. The goal was to prevent infinite loops when tool choice was set. The key change I'm making is:
1. Making it configurable on the agent.
2. Doing bookkeeping in the Runner to track this, to prevent mutating agents.
3. Not resetting the global tool choice in RunConfig.

## Test Plan:
Unit tests.
.
@rm-openai rm-openai merged commit ad020b7 into main Mar 25, 2025
10 checks passed
@rm-openai rm-openai deleted the rm/pr335 branch March 25, 2025 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants