fix(cli): fully filter session_meta from restored conversations#4790
Open
Disaster-Terminator wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(cli): fully filter session_meta from restored conversations#4790Disaster-Terminator wants to merge 1 commit intoNousResearch:mainfrom
Disaster-Terminator wants to merge 1 commit intoNousResearch:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes the CLI restored-session path so transcript-only metadata such as
session_metadoes not leak back into provider-facing conversation history.The issue is that resumed CLI conversations could restore raw session rows and reuse them as normal chat history. When those rows included non-transcript entries like
session_meta, strict chat-completions providers could reject the outgoing request because of unsupported roles.This change fixes that in two places:
This keeps the fix narrow and defensive:
conversation_historyRelated Issue
Fixes #4715
Type of Change
Changes Made
cli.py_init_agent()_preload_resumed_session()_handle_resume_command()session_metarun_agent.pyso unsupported roles are removed before provider calls_sanitize_api_messages()dropping unsupported roles_preload_resumed_session()filtering restored history_init_agent()resumed-session loading behavior_handle_resume_command()filtering/resumehistoryHow to Test
session_meta/resumecommandconversation_historycontains only transcript-safe rolessession_metapytest -q tests/test_agent_guardrails.py tests/test_resume_display.py tests/test_cli_resume_command.pyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs