Skip to content

Phase 1 / §31: agent-core typed contracts + adapters (additive, no behavior change)#1

Merged
Svaag merged 1 commit into
mainfrom
feat/agent-core-phase1-contracts
Jun 29, 2026
Merged

Phase 1 / §31: agent-core typed contracts + adapters (additive, no behavior change)#1
Svaag merged 1 commit into
mainfrom
feat/agent-core-phase1-contracts

Conversation

@Svaag

@Svaag Svaag commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

First safe milestone of the Agent Runtime Framework consolidation: a new, dependency-light
agent-core package of shared typed contracts plus test-only adapters for the three
priority loops. Spec: ../docs/migration/first-safe-milestone.md + file-level-change-plan.md.

Contents

  • agent_core/contracts/ — 22 pydantic v2 models (TaskEnvelope, AgentState,
    RunContext/RuntimeContext, TraceEvent, AuditEvent, CostUsage, ModelPolicy,
    RoutingDecision, ToolContract/ToolResult, EvidencePacket/SourceRef, DecisionPacket,
    HumanApproval{Request,Decision}, PolicyGateResult, FeedbackEvent, ErrorEnvelope,
    GraphSpec/NodeSpec/EdgeSpec). Importing them pulls in pydantic only (enforced by test).
  • agent_core/adapters/engineering_loop, noc_agent, knowledge: pure
    dict→contract mappers. Imported by tests only; not wired into any loop's runtime.
  • agent_core/contracts/graphs/ — descriptive draft GraphSpecs (eng 20 nodes, NOC 13,
    knowledge pipeline) that parse into GraphSpec.
  • Exported JSON schemas, fixtures from sanitized real loop shapes, CI (ruff/mypy/pytest +
    schema-export check).

Verification

  • ruff clean, mypy clean (19 files), 25 tests pass, schema export reproducible.

Safety / scope

  • Additive and behavior-preserving: no existing loop is modified or imported at runtime.
  • Out of scope (later phases): runtime, GraphSpec compiler, model router, tool/MCP
    registries, memory store, learning substrate, judges, policy gates, control-plane API/GUI.

🤖 Generated with Claude Code

Shared typed pydantic contracts + test-only adapters for the engineering, NOC, and knowledge loops, plus descriptive draft GraphSpecs. Additive and behavior-preserving: no existing loop is modified or imported at runtime.

Contracts: TaskEnvelope, AgentState, RunContext/RuntimeContext, TraceEvent, AuditEvent, CostUsage, ModelPolicy, RoutingDecision, ToolContract/ToolResult, EvidencePacket/SourceRef, DecisionPacket, HumanApprovalRequest/Decision, PolicyGateResult, FeedbackEvent, ErrorEnvelope, GraphSpec/NodeSpec/EdgeSpec. Adapters: engineering_loop, noc_agent, knowledge. Tests: 25 passing; ruff + mypy clean; CI added.

Refs: docs/migration/first-safe-milestone.md, docs/migration/file-level-change-plan.md

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17f6f7ea6b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pyproject.toml
dev = ["pytest>=8", "pyyaml>=6", "ruff>=0.5", "mypy>=1.8", "types-PyYAML"]

[tool.hatch.build.targets.wheel]
packages = ["agent_core"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a PEP 561 marker to the typed package

When agent-core is installed as a dependency instead of checked out as source, type checkers only trust inline annotations from third-party packages that ship a py.typed marker. This package is advertised as shared typed contracts, but the wheel package here contains no agent_core/py.typed, so downstream mypy/pyright users will see the contracts as untyped or skipped despite the annotations.

Useful? React with 👍 / 👎.

Comment thread scripts/export_schemas.py
Comment on lines +31 to +32
OUT_DIR.mkdir(parents=True, exist_ok=True)
for model in model_classes():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove stale schema files during export

If a contract is renamed or removed, this exporter writes the current models but leaves the old *.schema.json file in place; the existing schema test only iterates current models and CI's git diff will not flag an unchanged stale file. That can publish schemas for contracts that no longer exist, so the export should clear or compare the exact schema file set before writing.

Useful? React with 👍 / 👎.

@Svaag Svaag merged commit ffd5495 into main Jun 29, 2026
1 check passed
@Svaag Svaag deleted the feat/agent-core-phase1-contracts branch June 29, 2026 01:52
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