Phase 2: optional agent-core TraceEvent/CostUsage emission (additive, flag-gated)#20
Conversation
…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>
There was a problem hiding this comment.
💡 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" |
There was a problem hiding this comment.
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 👍 / 👎.
What
Phase 2 groundwork for the Agent Runtime Framework: emit standard
agent-coreobservability records from the knowledge loop, alongside existing behavior.
src/hyrule_knowledge/agent_core_trace.py—emit_context_pack(TraceEvent) andemit_enrich_cost(model_call TraceEvent carrying CostUsage).cli.py— additive calls incmd_context_pack(afterpack.as_json()) andcmd_enrich(non-dry-run).tests/test_agent_core_trace.py.Safety / additive guarantees
HYRULE_KNOWLEDGE_AGENT_CORE_TRACEtruthy and theoptional
agent-corepackage installed. Verified:enabled()==False,emit→None.agent-coreis not a declared dependency —agent_coreis imported dynamically viaimportlib, somypy --strict srcanduv sync --frozenare unaffected and CI withoutthe package simply skips the new test (
importorskip).HYRULE_KNOWLEDGE_AGENT_CORE_TRACE_PATH(default
reports/agent-core-trace.jsonl).Verification (local, with agent-core installed)
ruff check src testsclean,mypy --strict srcclean (36 files),pytest97 passed(3 new). Token/USD fidelity for enrichment is a tracked follow-up (usage not yet surfaced).
Companion to
AS215932/agent-corePR #1 (the contracts package).🤖 Generated with Claude Code