fix: handle missing fields in summary_template.format() to prevent KeyError#1401
Open
octo-patch wants to merge 3 commits intoagentscope-ai:mainfrom
Open
fix: handle missing fields in summary_template.format() to prevent KeyError#1401octo-patch wants to merge 3 commits intoagentscope-ai:mainfrom
octo-patch wants to merge 3 commits intoagentscope-ai:mainfrom
Conversation
fixes agentscope-ai#1392) The mcp python-sdk renamed `streamablehttp_client` to `streamable_http_client` in the streamable_http transport module. Update both the stateful and stateless HTTP MCP clients to use the new function name.
…agent (fixes agentscope-ai#1391) MCP registers tools with underscore names (tavily_search, tavily_extract) but the DeepResearch agent used hyphenated names (tavily-search, tavily-extract). This mismatch caused the follow-up extraction to never trigger and led to repeated redundant searches.
…yError (fixes agentscope-ai#1388) When the compression model omits optional fields like 'next_steps' from its structured output, calling summary_template.format(**metadata) raises a KeyError. Provide empty-string defaults for all expected template fields so partial summaries are formatted gracefully instead of crashing.
|
|
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.
Fixes #1388
Problem
When memory compression is enabled and the compression model generates a summary without all expected fields (e.g., omitting
next_steps), the call tosummary_template.format(**last_chunk.metadata)raises aKeyError. This causes the agent to crash intermittently during_compress_memory_if_needed().Solution
Build a dict with empty-string defaults for all template placeholder fields before calling
.format(). Known metadata values always override the defaults, so no existing field is dropped. This ensures partial summaries are formatted gracefully instead of crashing.Testing
Reproduce by running a ReActAgent with
compression_configenabled and a model that occasionally omits fields from its structured output. After the fix, the agent handles missing fields without raisingKeyError.