Skip to content

Comments

feat: add context configuration (compaction/compression/cache) support#1340

Open
dobesv wants to merge 4 commits intokagent-dev:mainfrom
dobesv:context-configs
Open

feat: add context configuration (compaction/compression/cache) support#1340
dobesv wants to merge 4 commits intokagent-dev:mainfrom
dobesv:context-configs

Conversation

@dobesv
Copy link
Contributor

@dobesv dobesv commented Feb 20, 2026

Summary

Adds context management configuration to agents, including:

  • Event compaction/compression: Configurable compaction of conversation history to reduce context size while preserving key information, with optional LLM-based summarization
  • Context caching: Prefix context caching at the provider level to reduce redundant processing
  • UI support: New ContextSection component for configuring compaction and caching in the agent creation/edit form

This is a subset of #1323, split per reviewer feedback to include only the context configuration changes (compaction/compression/cache), holding back the memory and resumability config changes for a follow-up PR.

Changes

Go (CRD + Controller)

  • Added ContextConfig, ContextCompressionConfig, ContextCacheConfig, and ContextSummarizerConfig types to v1alpha2 Agent CRD
  • Added AgentContextConfig, AgentCompressionConfig, and AgentCacheConfig to the ADK config types (go/pkg/adk/types.go)
  • Added context config translation in adk_api_translator.go including summarizer model resolution
  • Regenerated deepcopy and CRD manifests

Python (ADK Runtime)

  • Added ContextCompressionSettings, ContextCacheSettings, and ContextConfig Pydantic models
  • Added build_adk_context_configs() to convert config to ADK native types
  • Wired events_compaction_config and context_cache_config through KAgentAppAppRunner
  • Added unit tests for context config parsing and ADK object construction

UI (Next.js)

  • Added ContextSection component with compaction and cache configuration forms
  • Added ContextConfig and related TypeScript types
  • Integrated ContextSection into agent create/edit page

Dependencies

  • Added @radix-ui/react-switch for toggle UI components
  • Updated google-adk minimum version to >=1.25.0

Copilot AI review requested due to automatic review settings February 20, 2026 01:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds context management configuration support to agents, enabling event compaction/compression and context caching. The implementation spans the entire stack from UI to Python runtime, with proper type definitions, validation, and test coverage.

Changes:

  • Added context configuration types and UI components for managing event compaction and context caching
  • Implemented Go CRD schema, translator logic, and deployment data merging for summarizer models
  • Added Python ADK integration with proper config parsing and ADK native type construction

Reviewed changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ui/src/types/index.ts Added TypeScript interfaces for context configuration (compaction, cache, summarizer)
ui/src/components/ui/switch.tsx New Switch component for toggle UI using Radix UI primitives
ui/src/components/create/ContextSection.tsx Context management configuration form with compaction and cache settings
ui/src/components/AgentsProvider.tsx Added context field to AgentFormData and validation errors
ui/src/app/agents/new/page.tsx Integrated ContextSection component into agent creation page
ui/src/app/actions/agents.ts Pass context config from form data to agent spec
ui/package.json, ui/package-lock.json Added @radix-ui/react-switch dependency
python/uv.lock Updated google-adk (>=1.25.0) and other dependencies (google-auth, google-genai, litellm, mcp, pydantic, httpx)
python/samples/adk/basic/pyproject.toml Updated google-adk minimum version to 1.25.0
python/packages/kagent-adk/tests/unittests/test_context_config.py Comprehensive unit tests for context config parsing and ADK conversion
python/packages/kagent-adk/src/kagent/adk/types.py Added context config Pydantic models and build_adk_context_configs function
python/packages/kagent-adk/src/kagent/adk/cli.py Wired context config through KAgentApp initialization
python/packages/kagent-adk/src/kagent/adk/_a2a.py Added context config parameters to KAgentApp and App initialization
python/packages/kagent-adk/pyproject.toml Updated dependencies and removed memory extra (deferred to follow-up PR)
helm/kagent-crds/templates/kagent.dev_agents.yaml Added context config schema to Agent CRD
go/pkg/adk/types.go Added AgentContextConfig, AgentCompressionConfig, AgentCacheConfig types
go/internal/controller/translator/agent/adk_api_translator_test.go Added tests for context config translation and deployment data merging
go/internal/controller/translator/agent/adk_api_translator.go Implemented context config translation and mergeDeploymentData function
go/config/crd/bases/kagent.dev_agents.yaml Generated CRD with context config schema
go/api/v1alpha2/zz_generated.deepcopy.go Generated DeepCopy methods for new context config types
go/api/v1alpha2/agent_types.go Added CRD types for context management (ContextConfig, ContextCompressionConfig, ContextCacheConfig, ContextSummarizerConfig)
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dobesv and others added 3 commits February 23, 2026 12:06
Address PR review feedback:

- Remove trailing blank line in adk_api_translator.go
- Remove unused ADKSTSIntegration import from _a2a.py
- Replace _build_context_kwargs dict/**kwargs pattern with
  _build_context_configs returning typed tuple + explicit named params
- Sync uv.lock with pyproject.toml (memory extra removal)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…hint

- Use realistic placeholder values (150000 for token threshold, 3 for event retention size)
- Add helper text clarifying token threshold requires event retention size

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants