← Back to Pull requests

fix(harnesswire): wait for the harness to close after a host-side sink failure #233

Closed
unknown closed this pull request without merging on Oct 29, 2026 19:31 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 04:21 UTC
Author

Follow-up to #126, addressing https://github.com/agent-primitives/sessions/pull/126#discussion_r4408422668.

After #126, the host waits for the harness to close the Connect stream when a turn ends (up to 2s) or parks, so harnessnode can flush its spans before a suspend. A turn that failed on the host side, such as a model provider error, still cancelled Connect at once, so a quick Suspend could snapshot those harness spans unexported.

Change

  • When a sink call (model, output, tool call, report, usage) fails on the host side and the caller is still waiting, ClientHarness.Run half-closes the stream and waits up to 2s for the harness to end the RPC, the same bounded close as after EVENT_END. The harness's pending sink call sees end of stream, so it normally exits at once.

  • The turn still fails with the host's error, unchanged. A cancelled caller and harness protocol violations still tear the stream down at once.

  • spec.md WIRE-12, docs/observability.md and the unreleased harness-end-drain.md fragment describe the new case.
  • Testing

  • New host failed row in TestConnectSpanExportedBeforeTurnEnds: the harness's Connect span must be exported before Run returns after a provider error. It fails without the change.

  • go test -race ./... for the root and integrations/substrate, vet, golangci-lint, doc links and the changelog check pass.
  • Diff: 172 lines (+129 / -43) across 2 files Reviewer: aramase Review duration: 909m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.35) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 172 lines diff across 2 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.308
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #233"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 35.3% (MEDIUM) · Higher = larger blast radius
    35.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.3% · Safe to merge
    15.3%