Skip to content
This repository was archived by the owner on May 26, 2026. It is now read-only.

feat(kora): KR-CC3-CLEANUP-AND-DAEMON-PREP-MEGABUCKET — #189 follow-ups + daemon audit + upstream prep#192

Merged
rafe-walker merged 1 commit into
feature/phase2-upgradesfrom
feat/kora-KR-CC3-CLEANUP-AND-DAEMON-PREP-MEGABUCKET
May 24, 2026
Merged

feat(kora): KR-CC3-CLEANUP-AND-DAEMON-PREP-MEGABUCKET — #189 follow-ups + daemon audit + upstream prep#192
rafe-walker merged 1 commit into
feature/phase2-upgradesfrom
feat/kora-KR-CC3-CLEANUP-AND-DAEMON-PREP-MEGABUCKET

Conversation

@rafe-walker

Copy link
Copy Markdown
Owner

Summary

4-deliverable batched bucket: 2 code follow-ups to #189 + 2 research-only docs (in companion kora-docs PR linked below).

Deliverable A — escalation_reason structured telemetry field

Threaded through the existing telemetry layers:

  • `agent/cost_state_holder.py` — `record_inference(..., escalation_reason: Optional[str] = None)` plumbs to `record_call`
  • `agent/cost_ladder_wire.py` — `record_inference_from_response` forwards the kwarg
  • `kora_cli/telemetry/cost_telemetry.py` — `_RouteCounters.escalation_reason_breakdown: Dict[str, int]` lights up only when both `escalated_to_opus=True` AND reason is non-empty string
  • `kora_hermes_plugin/haiku_router/plugin.py` — handler now returns `{"reissue_with": ..., "escalation_reason": }`
  • `agent/conversation_loop.py` — reissue site reads `escalation_reason` from plugin result + passes to `record_inference_from_response`

After this lands, cost-telemetry snapshot exposes per-reason escalation breakdown — cockpit panels can show "X% low_confidence_marker, Y% short_response_for_long_input".

Deliverable B — api_call_count accounting confirmation

Per #189 PR body the chosen semantic was "transparent upgrade" — a re-issue is part of the same iteration; `api_call_count` is NOT incremented and `iteration_budget` is NOT consumed. Documented explicitly in:

Pinned by two structural tests that slice the loop source between the hook firing and the `post_api_request` observer and assert there's NO `api_call_count += 1` and NO `iteration_budget.consume(` in that slice.

Deliverables C + D — research only (separate docs PR)

Land in kora-docs at `kora_docs/14_research/`. Both available for review at:

Test plan

  • Deliverable A tests: 7 new test cases covering field plumbing (escalation_reason omitted / non-escalated / empty / non-string fallback / snapshot shape stability)
  • Deliverable B tests: 2 structural pins (no `api_call_count += 1` and no `iteration_budget.consume(` between hook firing and post_api_request observer)
  • Regression: 178/178 focused-scope tests pass (haiku_router + kora_hermes_plugin + cost_ladder + cost_telemetry + cost_telemetry_listener + post_llm_can_reissue)
  • Burn-in verification post-merge: confirm cockpit cost-telemetry panel reads the new `escalation_reason_breakdown` field (CC#2 follow-on if desired; not blocking)

🤖 Generated with Claude Code

…ion_reason + api_call_count pin)

Deliverable A: escalation_reason structured telemetry field. Threaded through CostStateHolder.record_inference → CostRouteTelemetry.record_call → _RouteCounters.escalation_reason_breakdown. haiku_router plugin now returns {"reissue_with": ..., "escalation_reason": <reason>}; conversation_loop reads the reason from the hook result and passes it to record_inference_from_response. Legacy callers omitting the field still work (escalation_count increments without per-reason bucket).

Deliverable B: api_call_count accounting confirmation. Per #189 PR body, re-issued calls are part of the same iteration ("transparent upgrade" semantic) — api_call_count NOT incremented, iteration_budget NOT consumed. Documented inline in haiku_router/plugin.py docstring + conversation_loop reissue site comment. Test pins both invariants by slicing the source between the hook firing and the post_api_request observer and asserting neither bump nor consume appears.

Deliverables C + D: research-only docs landing in a separate kora-docs PR. C audits all 16 daemon listeners against agent/background_daemon_registry.py + recommends 15-16 sequential PRs for KR-DAEMON-LISTENERS-VIA-GATEWAY (snapshot listener first as proof-of-pattern). D drafts 5 upstream-Hermes PRs for the local extensions added by #172/#181/#189; recommends submission order #1-3 (3+ days soak met) and holding #4 + #5 for the 7-day soak.

Tests: 178/178 focused-scope tests green (haiku_router + kora_hermes_plugin + cost_ladder + cost_telemetry + cost_telemetry_listener + post_llm_can_reissue). Includes 7 new tests covering escalation_reason structured-field semantics (omission/non-escalation/empty-string/non-string fallback) and the api_call_count + iteration_budget invariants.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rafe-walker rafe-walker merged commit 731b272 into feature/phase2-upgrades May 24, 2026
@rafe-walker rafe-walker deleted the feat/kora-KR-CC3-CLEANUP-AND-DAEMON-PREP-MEGABUCKET branch May 24, 2026 07:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant