Skip to content

fix: Drop the whole AFC exchange from curated chat history when the final model turn is invalid - #3315

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/1016479900
Open

copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/1016479900

Conversation

@copybara-service

Copy link
Copy Markdown

fix: Drop the whole AFC exchange from curated chat history when the final model turn is invalid

fixes #3314

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3249 from googleapis:release-please--branches--main 4b4b0f3

…inal model turn is invalid

fixes #3314

FUTURE_COPYBARA_INTEGRATE_REVIEW=#3249 from googleapis:release-please--branches--main 4b4b0f3
PiperOrigin-RevId: 1016479900

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The live AFC half fixes #3314. The rebuild half, which I asked for there, splits from the live path.

# git archive 1ffa74f (base afb10e8), uv venv, Python 3.12, genai.__file__ printed per tree
$ python -I afc_tail.py    # the script from #3314
afb10e8  curated: ['user:text', 'model:function_call']
1ffa74f  curated: []

$ python -m pytest google/genai/tests/chats/test_get_history.py -q
27 passed in 0.11s                    # 1ffa74f
7 failed, 20 passed in 0.29s          # chats.py from afb10e8, tests kept
# not run: the replay tests in tests/chats, which need credentials

non-blocking: a stored history can't tell AFC from manual calls. Send a function_response by hand, get a blocked answer, and only the rebuild drops the call:

$ python -I manual_fc.py    # FunctionDeclaration tool, send_message(Part.from_function_response(...)), SAFETY reply
afb10e8  live: ['user:text', 'model:function_call']  rebuilt via chats.create(history=...): same
1ffa74f  live: ['user:text', 'model:function_call']  rebuilt via chats.create(history=...): []

The caller can resend that response, and 2580638 ends turns on a call on purpose. My pick: drop _drop_rejected_input and its hand-built test and accept the #3314 tail on a restored AFC history. Or should the live manual path drop the call too?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Curated chat history ends on an unanswered function_call when the turn after AFC is invalid

2 participants