How opensage-agent/opensage-adk works
Purpose and Entry Points
OpenSage-ADK is a Python 3.12+ development kit for self-programming AI agents: agents can create sub-agent topologies, synthesize tools/skills, and maintain structured memory at runtime. Primary user entry points are the CLI and local web UI in src/opensage/cli/opensage_cli.py and src/opensage/cli/opensage_web_app.py. Custom agents expose an mk_agent(session_id, model=None) factory; runnable examples live under agent_library/.
Agent Runtime and Dynamic Topology
OpenSageAgent is the central agent abstraction at src/opensage/agents/opensage_agent.py. It is instantiated with model, instructions, tools, subagents, and enabled skills. The orchestration layer manages dynamically created agents, invocation, lifecycle, messaging, and persisted state through src/opensage/orchestration/manager.py, src/opensage/orchestration/instance.py, and src/opensage/orchestration/inbox.py. This is the control-plane boundary between an agent’s model loop and multi-agent execution, supporting sequential decomposition and parallel/ensemble patterns.
Sessions, Memory, and Context Management
A session binds runtime resources and services for an agent invocation in src/opensage/session/opensage_session.py, with sandbox and Neo4j managers in src/opensage/session/opensage_sandbox_manager.py and src/opensage/session/opensage_neo4j_client_manager.py. Memory is primarily file-based: cross-task knowledge storage is under src/opensage/memory/file_based/long_term/knowledge_store.py; per-task prompt, sandbox I/O, and session artifacts are handled in src/opensage/memory/file_based/short_term/. Summarization and in-memory session services in src/opensage/features/summarization.py and src/opensage/features/opensage_in_memory_session_service.py control context growth.
Tools, Skills, and Extensibility
The toolbox adapts executable capabilities into agent-callable tools, notably shell/skill execution in src/opensage/toolbox/general/bash_tool.py, staging/loading support in src/opensage/utils/bash_tools_staging.py, and tool normalization in src/opensage/toolbox/tool_normalization.py. Skills are packaged as SKILL.md-described command sets under src/opensage/bash_tools/, including code retrieval, static analysis, fuzzing, coverage, and software-engineering workflows. MCP toolset integrations are represented by providers such as src/opensage/toolbox/debugger/gdb_mcp/get_toolset.py.
Plugins modify agent-runtime behavior rather than application orchestration. Loaders are in src/opensage/plugins/adk_plugin_loader.py and src/opensage/plugins/claude_code_hook_loader.py; built-ins include budget enforcement, history summarization, tool-response summarization, and edit safeguards under src/opensage/plugins/default/adk_plugins/.
Sandbox and Analysis Infrastructure
Tool execution is isolated behind a sandbox interface and factory: src/opensage/sandbox/base_sandbox.py and src/opensage/sandbox/factory.py. Supported backends include local, Docker, remote Docker, Podman, Kubernetes, Nitrobox, and OpenSandbox (src/opensage/sandbox/local_sandbox.py, src/opensage/sandbox/native_docker_sandbox.py, src/opensage/sandbox/k8s_sandbox.py). Initializers provision optional analysis services such as CodeQL, Joern, fuzzing, coverage, GDB MCP, and Neo4j via src/opensage/sandbox/initializers/.
This boundary is material: agents request tools; tools operate within sandboxed workspaces and may depend on Docker, external containers, or remote infrastructure.
Models and External Services
Model selection and spending limits are centralized in src/opensage/llm/registry.py and src/opensage/llm/budget.py. The documented minimal agent uses Google ADK’s LiteLlm, so configured LLM providers require API credentials. Optional external integrations include Neo4j for graph-backed code/memory queries, Joern and CodeQL for static analysis, MCP servers for debugger/binary tools, and web search (src/opensage/toolbox/general/web_search_tool.py).
Evaluation and Distribution Surfaces
Benchmark adapters dispatch agents across native or Ray execution in src/opensage/evaluation/dispatchers/native.py and src/opensage/evaluation/dispatchers/ray.py. Benchmark implementations under benchmarks/ cover SWE-bench Pro, CyberGym, CVEGym, DevOpsGym, Harbor, and related environments. RL adapters bridge the runtime to AREAL, Slime, Miles, and NeMo-style environments under src/opensage/evaluation/rl_adapters/. Example agents are the practical integration surface: agent_library/agents_101/, agent_library/agents_with_features/, and task-oriented agents in agent_library/agents/.
Main entry points: opensage_agent.py OpenSageAgent · tool_normalization.py Toolbox · manager.py Orchestration manager · opensage_session.py OpenSage session
Components 20
Entry & Examples
- CLI
src/opensage/cli/opensage_cli.py - Local web UI
src/opensage/cli/opensage_web_app.py - Example agents · Agents expose an mk_agent(session_id, model=None) factory.
Agent Runtime
- OpenSageAgent · Combines model, instructions, tools, subagents, and skills.
src/opensage/agents/opensage_agent.py - Orchestration manager · Manages dynamic agents, invocation, lifecycle, and persisted state.
src/opensage/orchestration/manager.py - Agent instances
src/opensage/orchestration/instance.py - Agent inbox
src/opensage/orchestration/inbox.py - OpenSage session · Binds services and runtime resources per invocation.
src/opensage/session/opensage_session.py - File-based memory · Stores cross-task knowledge plus task prompts, I/O, and artifacts.
src/opensage/memory/file_based/long_term/knowledge_store.py - Context services · Controls context growth with summaries and in-memory sessions.
src/opensage/features/summarization.py - LLM registry & budget · Selects providers and enforces spending limits.
src/opensage/llm/registry.py
Execution & Extensions
- Toolbox · Normalizes executable capabilities into agent-callable tools.
src/opensage/toolbox/tool_normalization.py - Skill packages · Code retrieval, analysis, fuzzing, coverage, and engineering workflows.
- Runtime plugins · Loads budget, history, tool-response, and edit-safety hooks.
src/opensage/plugins/adk_plugin_loader.py - Sandbox factory · Selects local, container, remote, Kubernetes, and other backends.
src/opensage/sandbox/factory.py - Analysis initializers · Provisions CodeQL, Joern, fuzzing, coverage, GDB MCP, and Neo4j.
- MCP & web integrations · Provides debugger/binary MCP tools and web search.
src/opensage/toolbox/debugger/gdb_mcp/get_toolset.py
Evaluation
- Benchmark dispatch · Runs agents through native or Ray execution.
src/opensage/evaluation/dispatchers/native.py - Benchmark suites · Includes SWE-bench Pro, CyberGym, CVEGym, DevOpsGym, and Harbor.
- RL adapters · Connects the runtime to AREAL, Slime, Miles, and NeMo-style environments.
Connections 20
- CLI → Example agents: loads agents
- Local web UI → Example agents: loads agents
- Example agents → OpenSageAgent: constructs
- OpenSageAgent → Orchestration manager: delegates topology
- Orchestration manager → Agent instances: creates
- Orchestration manager → Agent inbox: routes messages
- OpenSageAgent → OpenSage session: invokes with
- OpenSage session → File-based memory: persists context
- Context services → File-based memory: summarizes
- OpenSageAgent → LLM registry & budget: uses model
- OpenSageAgent → Toolbox: requests tools
- OpenSageAgent → Runtime plugins: extends behavior
- Toolbox → Skill packages: executes skills
- Toolbox → Sandbox factory: runs in
- OpenSage session → Sandbox factory: manages workspace
- Sandbox factory → Analysis initializers: provisions
- Toolbox → MCP & web integrations: integrates
- Benchmark dispatch → OpenSageAgent: evaluates
- Benchmark dispatch → Benchmark suites: dispatches across
- RL adapters → OpenSageAgent: bridges runtime