Skip to content

fix(apps): preserve compaction language anchor#6278

Closed
Sehlani042 wants to merge 4 commits into
google:mainfrom
Sehlani042:codex/repro-adk-compaction-language
Closed

fix(apps): preserve compaction language anchor#6278
Sehlani042 wants to merge 4 commits into
google:mainfrom
Sehlani042:codex/repro-adk-compaction-language

Conversation

@Sehlani042

Copy link
Copy Markdown

Refs #6273

Summary

  • add an explicit language-anchor requirement to the default LlmEventSummarizer prompt
  • preserve the conversation language and response-language convention when they are evident from the compacted history
  • add a regression test covering an English user turn followed by a foreign-language tool response

Why

The issue reports long-lived sessions drifting to another language after repeated event compaction plus large retrieved tool payloads. This is a narrow prompt-contract mitigation: it makes the compaction summary request preserve the conversation language signal instead of producing a language-neutral summary that later turns can overrun.

This does not claim to fully solve every long-context language drift case; it only hardens the default summarizer behavior at the compaction boundary.

Verification

  • RED: uv run --extra test pytest tests/unittests/apps/test_llm_event_summarizer.py::TestLlmEventSummarizer::test_default_prompt_preserves_conversation_language_anchor -q failed before the prompt change because the default prompt lacked the language-anchor instruction
  • GREEN: uv run --extra test pytest tests/unittests/apps/test_llm_event_summarizer.py::TestLlmEventSummarizer::test_default_prompt_preserves_conversation_language_anchor -q
  • uv run --extra test pytest tests/unittests/apps/test_llm_event_summarizer.py -q
  • uv run --extra dev ruff check src/google/adk/apps/llm_event_summarizer.py tests/unittests/apps/test_llm_event_summarizer.py
  • uv run --extra dev pyink --check src/google/adk/apps/llm_event_summarizer.py tests/unittests/apps/test_llm_event_summarizer.py
  • git diff --check

@google-cla

google-cla Bot commented Jul 3, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Sehlani042 Sehlani042 marked this pull request as ready for review July 4, 2026 04:20
@rohityan rohityan self-assigned this Jul 6, 2026
@rohityan rohityan added the core [Component] This issue is related to the core interface and implementation label Jul 6, 2026
@rohityan

rohityan commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Hi @Sehlani042 , Thank you for your contribution! We appreciate you taking the time to submit this pull request.
While this PR cleanly addresses the language drift aspect, another pull request #6329 was submitted shortly after that implements structured CRITICAL INSTRUCTIONS headers to solve both the language drift and the tool grounding loss in a single prompt update.
To ensure we completely cover both aspects of Issue #6273 with structured metadata anchors, we are going to consolidate the resolution into #6329 and close this PR as superseded.

@rohityan

rohityan commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Closing this as a du

@rohityan rohityan closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants