Skip to content

fix(tools): materialize input_examples iterable to retain examples across turns (#1990) - #2002

Open
iosayin wants to merge 1 commit into
anthropics:mainfrom
iosayin:fix/1990-materialize-input-examples
Open

iosayin wants to merge 1 commit into
anthropics:mainfrom
iosayin:fix/1990-materialize-input-examples

Conversation

@iosayin

@iosayin iosayin commented Oct 7, 2026

Copy link
Copy Markdown

Fixes #1990

Summary

When a generator or single-use iterator is passed as input_examples to beta_tool / beta_async_tool, BaseFunctionTool retained it directly. The first request/serialization consumed the iterator, causing subsequent requests in a conversation turn to serialize input_examples as [], silently losing the tool input examples.

Changes

  • In BaseFunctionTool.__init__, materialized input_examples as a list if not None (list(input_examples) if input_examples is not None else None).
  • Added a unit test in tests/lib/tools/test_functions.py verifying that generator-backed input_examples persist across repeated to_dict() serializations.

@iosayin
iosayin requested a review from a team as a code owner October 7, 2026 00:54

This branch has not been deployed

No deployments
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.

Generator-backed tool input examples disappear from follow-up requests

1 participant