fix(compaction): preserve namespaced tool names in LLM summarizer prompt#1907
fix(compaction): preserve namespaced tool names in LLM summarizer prompt#1907yashrajshuklaaa wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a compaction-related failure where the LLM summarizer could abbreviate namespaced tool/agent names (e.g., dropping kagent__...__ prefixes), causing the orchestrator to later reference non-existent tools after context compaction.
Changes:
- Introduces a kagent-specific default compaction prompt that instructs the summarizer to preserve exact registered tool/agent names (including namespace prefixes).
- Updates
build_adk_context_configsto use the kagent default prompt when no customprompt_templateis provided. - Adds unit tests to ensure the default prompt is applied and that a user-provided prompt remains respected.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
python/packages/kagent-adk/src/kagent/adk/types.py |
Adds _KAGENT_COMPACTION_PROMPT and uses it as the default summarizer prompt when prompt_template is not provided. |
python/packages/kagent-adk/tests/unittests/test_context_config.py |
Adds tests verifying the default prompt selection and that custom prompts are not overridden. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3773dee to
828afb4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
python/packages/kagent-adk/tests/unittests/test_context_config.py:207
- This assertion relies on LlmEventSummarizer’s private
_prompt_templateattribute; using a publicprompt_templateattribute when available (and falling back) will make the test more resilient across google-adk versions.
assert events_cfg.summarizer._prompt_template == ""
828afb4 to
3b24d4a
Compare
3b24d4a to
95c5224
Compare
EItanya
left a comment
There was a problem hiding this comment.
Thanks so much for the fix. What happens if the user does provide a prompt template, do we always want to append the bit about tool name correctness?
|
@EItanya great point i prefer 2nd one cuz appending the warning is a small change but saves users from a confusing failure |
sounds good let's do it |
after context compaction the LlmEventSummarizer rewrote conversation history using an LLM. also the default ADK prompt had no instruction to preserve exact tool names so the LLM abbreviated namespaced tool names like 'kagent__default__agent_name_aa' to just 'agent_name_aa'.when the orchestrator agent resumed after compaction it could not dispatch to the sub-agent because the short name does not match the registered tool name Fix: inject a kagent-specific default prompt_template that explicitly instructs the summarizer LLM to preserve exact tool/agent names including namespace prefixes.users who supply a custom prompt_template are unaffected (their value takes precedence via 'or') Fixes kagent-dev#1550 Signed-off-by: Yashraj Shukla <shuklayashraj68@gmail.com>
7360525 to
41c6b72
Compare
|
@EItanya done |
after context compaction the LlmEventSummarizer rewrote conversation history using an LLM.
also the default ADK prompt had no instruction to preserve exact tool names so the LLM abbreviated namespaced tool names like 'kagent__default__agent_name_aa' to just 'agent_name_aa'
when the orchestrator agent resumed after compaction it could not dispatch to the sub-agent because the short name does not match the registered tool name
Fix: inject a kagent-specific default prompt_template that explicitly instructs the summarizer LLM to preserve exact tool/agent names including namespace prefixes.users who supply a custom prompt_template are unaffected (their value takes precedence via 'or')
Fixes #1550