Skip to content

Syntax error in EventsCompactionConfig snippet in context compaction documentation #6864

Description

@chaotingxuan

Describe the bug

In docs/context/compaction.md (under "Sliding window compaction", lines 73-78), the Python code snippet illustrating EventsCompactionConfig contains a syntax error: the call to EventsCompactionConfig(...) has an unclosed parenthesis, causing a SyntaxError: '(' was never closed. In addition, the snippet omits the import for EventsCompactionConfig.


To Reproduce

Steps to reproduce the behavior:

  1. Go to docs/context/compaction.md#sliding-window-compaction.
  2. Inspect the Python code snippet under "Sliding window compaction":
    # (Optional) Event-based, sliding window as supplementary setting
    compaction_config = EventsCompactionConfig(
        compaction_interval=10,   # Number of turns between standard compactions
        overlap_size=2,           # Number of events to retain as overlapping context
  3. Attempt to run or parse the Python snippet.
  4. Observe SyntaxError: '(' was never closed.

Expected behavior

The Python sample snippet should be syntactically valid, with the call properly closed with ) and the class imported from google.adk.apps.app.


Screenshots

N/A (Documentation syntax error)


Versions

  • OS: macOS / Linux / Windows
  • ADK version: 2.0.0
  • Python version: 3.10+

Additional context

A patch is prepared and available in attachment.

fix-context-docs-code-samples.patch

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent config[Component] This issue is related to the Agent Config interface and implementation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions