Skip to content

feat(tools): add conversation history support to ToolContext #904 #926

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

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

Conversation

SDGLBL
Copy link

@SDGLBL SDGLBL commented Jun 24, 2025

Added conversation history tracking to ToolContext to provide tools with access to the full conversation context when they are invoked. The history includes the original input and all items generated during the agent run up to the point of tool invocation.

Key changes:

  • Added conversation_history field to ToolContext with documentation
  • Updated from_agent_context to accept and store conversation history
  • Modified tool execution in RunImpl to build and pass conversation history
  • Added comprehensive tests for conversation history functionality

The conversation history is built from:

  1. Original input (converted to input items)
  2. Items from previous steps (pre_step_items)
  3. Items from current step (new_step_items)

This enables tools to have full context of the conversation when processing requests.

Resolves #904

Added conversation history tracking to ToolContext to provide tools with access to the full conversation context when they are invoked. The history includes the original input and all items generated during the agent run up to the point of tool invocation.

Key changes:
- Added conversation_history field to ToolContext with documentation
- Updated from_agent_context to accept and store conversation history
- Modified tool execution in RunImpl to build and pass conversation history
- Added comprehensive tests for conversation history functionality

The conversation history is built from:
1. Original input (converted to input items)
2. Items from previous steps (pre_step_items)
3. Items from current step (new_step_items)

This enables tools to have full context of the conversation when processing requests.
@seratch seratch added enhancement New feature or request feature:core labels Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When running in non-streaming mode, retrieve past history during tool execution.
2 participants