feat: add context configuration (compaction/compression/cache) support#1340
feat: add context configuration (compaction/compression/cache) support#1340dobesv wants to merge 1 commit intokagent-dev:mainfrom
Conversation
There was a problem hiding this comment.
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.
|
|
||
|
|
There was a problem hiding this comment.
There are extra blank lines at the end of the file. Remove the trailing empty lines after line 1441.
| 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 |
There was a problem hiding this comment.
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.
Summary
Adds context management configuration to agents, including:
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)
ContextConfig,ContextCompressionConfig,ContextCacheConfig, andContextSummarizerConfigtypes tov1alpha2Agent CRDAgentContextConfig,AgentCompressionConfig, andAgentCacheConfigto the ADK config types (go/pkg/adk/types.go)adk_api_translator.goincluding summarizer model resolutionPython (ADK Runtime)
ContextCompressionSettings,ContextCacheSettings, andContextConfigPydantic modelsbuild_adk_context_configs()to convert config to ADK native typesevents_compaction_configandcontext_cache_configthroughKAgentApp→App→RunnerUI (Next.js)
ContextSectioncomponent with compaction and cache configuration formsContextConfigand related TypeScript typesDependencies
@radix-ui/react-switchfor toggle UI componentsgoogle-adkminimum version to>=1.25.0