Skip to content

Phase 2: optional agent-core TraceEvent/CostUsage emission (additive, flag-gated)#20

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

Phase 2: optional agent-core TraceEvent/CostUsage emission (additive, flag-gated)#20
Svaag merged 1 commit into
mainfrom
feat/agent-core-trace-emission

Conversation

@Svaag

@Svaag Svaag commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Phase 2 groundwork for the Agent Runtime Framework: emit standard agent-core
observability records from the knowledge loop, alongside existing behavior.

  • src/hyrule_knowledge/agent_core_trace.pyemit_context_pack (TraceEvent) and
    emit_enrich_cost (model_call TraceEvent carrying CostUsage).
  • cli.py — additive calls in cmd_context_pack (after pack.as_json()) and
    cmd_enrich (non-dry-run).
  • tests/test_agent_core_trace.py.

Safety / additive guarantees

  • No-op by default. Requires HYRULE_KNOWLEDGE_AGENT_CORE_TRACE truthy and the
    optional agent-core package installed. Verified: enabled()==False, emit→None.
  • agent-core is not a declared dependency — agent_core is imported dynamically via
    importlib, so mypy --strict src and uv sync --frozen are unaffected and CI without
    the package simply skips the new test (importorskip).
  • Best-effort: any emission error is swallowed; the command's output never changes.
  • Records append as JSON lines to HYRULE_KNOWLEDGE_AGENT_CORE_TRACE_PATH
    (default reports/agent-core-trace.jsonl).

Verification (local, with agent-core installed)

  • ruff check src tests clean, mypy --strict src clean (36 files), pytest 97 passed
    (3 new). Token/USD fidelity for enrichment is a tracked follow-up (usage not yet surfaced).

Companion to AS215932/agent-core PR #1 (the contracts package).

🤖 Generated with Claude Code

…itive)

Flag-gated, best-effort observability groundwork for the Agent Runtime Framework. Emits standard agent-core TraceEvent (context packs) and CostUsage-bearing model_call events (enrichment) ALONGSIDE existing behavior. No-op unless HYRULE_KNOWLEDGE_AGENT_CORE_TRACE is truthy and the optional agent-core package is installed (NOT a declared dependency; CI without it skips emission). agent_core is imported dynamically so 'mypy --strict src' and 'uv sync --frozen' are unaffected.

Files: src/hyrule_knowledge/agent_core_trace.py (emit_context_pack/emit_enrich_cost); cli.py additive calls in cmd_context_pack + cmd_enrich; tests/test_agent_core_trace.py (importorskip). ruff + mypy --strict clean; full suite 97 passed; off by default (no behavior change).

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: 462456c035

ℹ️ 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".


FLAG_ENV = "HYRULE_KNOWLEDGE_AGENT_CORE_TRACE"
PATH_ENV = "HYRULE_KNOWLEDGE_AGENT_CORE_TRACE_PATH"
_DEFAULT_PATH = "reports/agent-core-trace.jsonl"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require an explicit out-of-tree trace sink

When HYRULE_KNOWLEDGE_AGENT_CORE_TRACE is enabled without setting HYRULE_KNOWLEDGE_AGENT_CORE_TRACE_PATH, this defaults raw agent-core traces into reports/agent-core-trace.jsonl inside the repository. The emitted context-pack payload includes the raw task text via task.summary and task_summary sections, and reports/ is not gitignored while the repo guide explicitly says to keep live traces/telemetry out of git except deterministic fixtures. Please default to a gitignored/out-of-tree location or require an explicit sink path so an enabled local run does not create commit-ready live trace data.

Useful? React with 👍 / 👎.

@Svaag Svaag merged commit 4b689a7 into main Jun 29, 2026
1 check passed
@Svaag Svaag deleted the feat/agent-core-trace-emission 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