Skip to content

Comments

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

Open
dobesv wants to merge 1 commit intokagent-dev:mainfrom
dobesv:context-configs
Open

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

Conversation

@dobesv
Copy link

@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.

Comment on lines +1442 to +1443


Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

There are extra blank lines at the end of the file. Remove the trailing empty lines after line 1441.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +23
from a2a.types import AgentCard, Task, TaskState, TaskStatusUpdateEvent
from agentsts.adk import ADKSTSIntegration, ADKTokenPropagationPlugin
from fastapi import FastAPI, Request
from fastapi.responses import PlainTextResponse
from google.adk.agents import BaseAgent
from google.adk.agents.context_cache_config import ContextCacheConfig as AdkContextCacheConfig
from google.adk.apps import App
from google.adk.apps.app import EventsCompactionConfig
from google.adk.artifacts import InMemoryArtifactService
from google.adk.plugins import BasePlugin
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.tools.mcp_tool import SseConnectionParams, StreamableHTTPConnectionParams
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The imports Task, TaskState, TaskStatusUpdateEvent, SseConnectionParams, and StreamableHTTPConnectionParams on lines 11 and 23 are added but not used in this file. These should be removed to keep the imports clean.

Copilot uses AI. Check for mistakes.
@dobesv dobesv closed this Feb 21, 2026
@dobesv dobesv reopened this Feb 21, 2026
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.

1 participant