BAIEnterprise Digitalization · AI Application Development中文EN

General Agent Framework & Toolkit

Period: 2026.09Status: FrozenType: Original workTags: Agent Runtime · Middleware · Tool authorization · Sandbox · Domain packsRepository ↗

A runtime and governance toolkit factored out of the generally useful parts of the Consulting Agent.

General Agent Framework & Toolkit

By the third generation of the Consulting Agent, looking back, a lot of it actually had nothing to do with consulting: how tasks execute, how tools get authorized, how problems get audited, how a long task resumes after breaking. Those capabilities would have to be rewritten for every new scenario, so I factored them out into a general runtime, aiming for governable, recoverable, and extensible. Its runtime core wasn’t written from zero either: it grew out of the middle layer of an earlier LangGraph basic-agent exercise of mine (the middle branch of the Agent learn project), which the consulting project used over and over before I decided to pull it out as its own set.

What the baseline contains

The migration baseline keeps the parts already validated in the consulting project:

  • A LangGraph agent execution graph: the full flow of task understanding, planning, execution, and answering;
  • A whole row of Middleware: planning, tool execution, context, safety, error handling, Checkpoint, human confirmation, and observability;
  • Tool registration, a unified tool-result contract, Scope authorization, and audit;
  • VFS, Sandbox, network-egress, and file-operation boundaries;
  • A multi-provider / multi-model LLM Gateway with failure failover;
  • Skill Runtime, Memory, query-side RAG, Evidence, and citations;
  • SubAgents, asynchronous tasks, task Workers, and recovery mechanisms;
  • Offline evaluation and retrieval evaluation.

In code layout, the core lives in agent_core/ (Runtime, Middleware, tools, shared capability contracts, the production control plane, SubAgents, evaluation, and storage); config/ holds configuration templates for authorization, risk, models, context, and retrieval; scenarios/ holds UI-independent scenario declarations — one scenario declaration selects which Runtime, Pack, Tool, Skill, and governance mode to use, and can be validated and run from the command line; there is also a capability catalog searchable by Pack, shared capability, rule, template, and evaluation, and Packs go through two checks — validate and release-check — before going live.

Runtime and domain Packs

The division of labor is drawn like this:

General Agent Runtime
  → general planning, tasks, and human checkpoints
  → general tools, Skill, Memory, RAG, and Sandbox
  → general governance, evaluation, source lifecycle, and run observability
  → domain Packs (consulting / bid response / policy analysis / R&D projects …)

Consulting Agent V2 / V3 was the first domain Pack plugged in; consulting’s business objects are not written into the Runtime core. The Packs currently in the repository are Reference, Evidence Work, Agent-led Governance, Consulting, Tender, Legal Research, and Academic Research; formal domain capabilities migrate into Packs, and skills/ keeps only examples.

The governance chain closed at the P4 stage: Pack tools go through Registry → Authorization → Sandbox → Executor → Audit; a tool must declare its authorization metadata in ToolSpec.authorization, and a missing declaration means default deny; Packs are assembled into the Runtime through RuntimeFactory and CapabilityGateway; Workers use atomic leases, heartbeats, and ControlPlaneLeaseFence to prevent duplicate execution; the external Sandbox Runner is a fixed command with no shell, with timeouts, process-group termination, output caps, and a JSON protocol; TaskStore provides persisted side-effect receipts with namespace isolation, so submitting the same external action twice doesn’t execute it twice.

Acceptance is layered

This system’s acceptance record has three layers, and the README states them plainly — I’ll relay them as written. P3’s local Runtime, Task / Run / Thread, Worker leases, and local RAG have automated acceptance; the real model and external retrieval are probed separately with --live, and are explicitly marked skipped when a Key or human authorization is missing — only an explicit --allow-live-network actually makes outbound calls. P4 verifies the production-replacement boundary (the governance chain above), and explicitly does not dress up undeployed Postgres, container / micro-VM, and real external services as passing. PostgresTaskStore itself is implemented: connection pool, connection and statement timeouts, optional enforced SSL, schema migration versions, readiness checks; the acceptance script checks the pool’s fsync / synchronous_commit, the Task / Run / Thread lifecycle, lease takeover and fencing, concurrent SKIP LOCKED claiming, cross-instance persistence, and idempotent replay of side-effect receipts — and a “production-shape” control-plane acceptance has been run against a real local PostgreSQL. The default backend is still SQLite; without an explicitly configured DSN it connects to no external database. The migration baseline recorded 477 tests passing, and local Keycloak and Vault integrations working are on the acceptance checklist as well.

Boundaries

The blunt part up front: locally accepted is not the same as production accepted. The README’s follow-up list names five unfinished things: run the Postgres acceptance in the target environment and fill in HA, backup/restore, and failure drills; replace the current command sandbox with a container or micro-VM Runner and validate isolation and network policy in the target environment; wire the live probes into a CI / pre-release environment that has credentials and approvals; connect Memory governance to production shared persistence and settle the cross-service namespace policy; and, once concrete domain Packs are plugged in, do multi-instance Worker load testing and failure drills. So the “framework” on this page is, precisely, a framework with a fairly complete local baseline — not a product you could pick up and ship. The migration also has explicit boundaries: real model keys, runtime artifacts, Checkpoints, personal and project memory, real project material, and local indexes never go into Git; the repository holds only reproducible source code, tests, configuration templates, example Skills, an example knowledge base, and architecture documents.

Designed and built by me, using open-source components such as LangGraph during construction.

Diagrams

graph LR
  A[Task request] --> B[Scenario assembly]
  B --> C[Runtime graph]
  C --> D[Registry]
  D --> E[Authorization]
  E --> F[Sandbox]
  F --> G[Execution]
  G --> H[Audit trail]
  H --> I[Domain Pack]
Main flow
graph TB
  subgraph L1["Runtime core"]
    R[Execution graph]
    M[Middleware]
    W[Workers + recovery]
  end
  subgraph L2["Shared capabilities"]
    T[Tools + gateway]
    K[Skill + Memory]
    G[RAG + Evidence]
    S[Sandbox]
  end
  subgraph L3["Storage layer"]
    DB[(TaskStore)]
    CK[Checkpoints]
  end
  subgraph L4["Domain Packs"]
    P1[Consulting Pack]
    P2[Tender Pack]
    P3[Other Packs]
  end
  R --> T
  R --> M
  T --> S
  R --> DB
  W --> CK
  R --> P1
  R --> P2
  R --> P3
System architecture