Skip to content

feat: CYPACK→CYHOST error telemetry pipeline for Mixpanel#975

Open
cyrusagent wants to merge 2 commits intomainfrom
cypack-951
Open

feat: CYPACK→CYHOST error telemetry pipeline for Mixpanel#975
cyrusagent wants to merge 2 commits intomainfrom
cypack-951

Conversation

@cyrusagent
Copy link
Copy Markdown
Contributor

@cyrusagent cyrusagent commented Mar 13, 2026

Summary

Implements the CYPACK side of the error telemetry pipeline that reports agent session errors back to CYHOST for Mixpanel tracking. When agents crash, stall, hit rate limits, or exceed turn limits on CYPACK droplets, error events are now POSTed back to CYHOST which has the team/user identity context needed for analytics.

  • Extract X-Cyrus-Callback-Token, X-Cyrus-Callback-URL, and X-Cyrus-Team-Id headers from CYHOST-forwarded webhooks in LinearEventTransport
  • New TelemetryReporter service that POSTs error events to CYHOST's callback endpoint with Bearer token auth
  • AgentSessionManager.completeSession() classifies session errors into 5 types (crash, stall, rate_limit, billing, max_turns) and reports them via fire-and-forget callback
  • Graceful degradation: silently skips telemetry when no callback headers are present (self-hosted, direct mode, older CYHOST)

Implementation

Header extraction (LinearEventTransport): Callback context is captured once from the first proxy webhook and stored on the transport instance. All three headers must be present; partial headers are ignored.

Error classification (AgentSessionManager): Maps SDK result messages to error types by checking subtype (e.g., error_max_turns) and scanning error text for keywords (rate_limit, billing, timeout, etc.). Falls back to crash for unrecognized errors.

Reporting (TelemetryReporter): Fire-and-forget HTTP POST with 10s timeout. Never blocks session completion. Logs warnings on failure but never throws.

Wiring (EdgeWorker): Creates TelemetryReporter with null context at startup, lazily forwards callback context from transport on first webhook message.

Testing

  • 4 tests for callback header extraction (extraction, missing headers, partial headers, idempotency)
  • 6 tests for TelemetryReporter (auth, graceful degradation, error handling, lazy context, timestamps)
  • 8 tests for AgentSessionManager telemetry integration (error classification for all 5 types, success skipping, non-blocking behavior, error message extraction)
  • All 596 package tests passing, lint clean, typecheck clean

Linear Issue

CYPACK-951

cyrusagent and others added 2 commits March 13, 2026 10:34
Extract callback headers (X-Cyrus-Callback-Token, X-Cyrus-Callback-URL,
X-Cyrus-Team-Id) from CYHOST-forwarded webhooks in LinearEventTransport.
Create TelemetryReporter service that POSTs error events back to CYHOST
for Mixpanel tracking. Hook into AgentSessionManager.completeSession()
to classify and report session errors (crash, stall, rate_limit, billing,
max_turns). Fire-and-forget with graceful degradation when no callback
context is available.

CYPACK-951

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cyrusagent cyrusagent changed the title feat: CYPACK→CYHOST error telemetry pipeline feat: CYPACK→CYHOST error telemetry pipeline for Mixpanel Mar 13, 2026
@cyrusagent cyrusagent marked this pull request as ready for review March 13, 2026 17:36
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