Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: P2 EarlyHint callback channel for cost gating#882

Merged
jackwener merged 2 commits into
mainfrom
coding-claude-opus/p2-early-hint
Apr 8, 2026
Merged

feat: P2 EarlyHint callback channel for cost gating#882
jackwener merged 2 commits into
mainfrom
coding-claude-opus/p2-early-hint

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Add EarlyHint type and optional onEarlyHint callback to GenerateVerifiedOptions
  • Emit structured hints at 3 stage boundaries: explore, synthesize, cascade
  • Pure internal cost gate — does not change GenerateOutcome terminal contract

Design

  • continue: true hints carry stage + confidence + candidate? (candidate only on synthesize/cascade)
  • continue: false hints immediately followed by existing P1 terminal return
  • unsupported-required-args goes directly to P1 — no P2 hint emitted (guardrail)
  • No hint buffering, replay, or persistence (v1)
  • Fully optional: existing callers unaffected

Test plan

  • 13 tests pass (7 existing + 6 new P2 hint tests)
  • tsc --noEmit clean
  • Explore stop hint (no API surface)
  • Explore continue + synthesize stop (no candidate)
  • Full success path (explore + synthesize + cascade continue hints with candidate)
  • Cascade stop hint (auth-too-complex)
  • unsupported-required-args does NOT emit synthesize hint (P1-only guardrail)
  • No errors when onEarlyHint not provided

Add optional onEarlyHint callback for internal cost gating before verify stage.

- EarlyHint type: version, stage, continue, reason, confidence, candidate?
- 3 emit points: explore (viable/not), synthesize (candidate/not), cascade (auth/ok)
- candidate only on synthesize/cascade + continue:true (not on stop or explore)
- unsupported-required-args goes directly to P1 terminal, no P2 hint emitted
- 6 new tests covering all hint paths + guardrails
@jackwener jackwener merged commit 991c8ce into main Apr 8, 2026
11 checks passed
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