Skip to content

feat(routing): route harness-protocol turns up, never down; auto-detect claimed-tool-unavailable - #935

Open
devin-ai-integration[bot] wants to merge 8 commits into
mainfrom
devin/1787058347-harness-escalation-gate
Open

feat(routing): route harness-protocol turns up, never down; auto-detect claimed-tool-unavailable#935
devin-ai-integration[bot] wants to merge 8 commits into
mainfrom
devin/1787058347-harness-escalation-gate

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Rewrite of #921 by @makosblade (all credit for the design and implementation to them) — reimplemented on a fresh branch off main to align with internal conventions and fix two bugs found in review.

Behavior (as in the original PR):

  • New turn types HarnessMeta, SubAgentHarnessMeta, Recovery in internal/router/turntype, with Base() mapping back to the stable policy vocabulary and HarnessEscalation() marking turns that must be served by a strong Claude-family model. applyHarnessEscalation clamps the per-turn decision (runTurnLoop = runTurnLoopInner + clamp) to Anthropic Opus — per-turn only, never written to session pins. Kill switch: ROUTER_HARNESS_ESCALATION_ENABLED.
  • Claimed-tool-unavailable auto-feedback: post-stream detector scans the captured response for a declared tool name near an "unavailable" phrase and persists a source="auto" negative RouterFeedbackEvent (claimed-tool-unavailable:<tool>), deduped per (session, role, tool) via expiring LRU. Persist-only; never influences live routing.
  • New helpers: catalog.IsClaudeFamily, translate.ClaudeCodeOnlyToolNames(), translate.ReasonHarnessEscalation, RequestEnvelope.LastUserToolResultErrorText.

Fixes over #921:

  • NewService now initializes claimedToolTracker (it only initialized spiralTracker, so the nil guard in maybeReportClaimedToolUnavailable made the auto-feedback path dead in production). Regression test constructs via NewService and asserts a row persists.
  • SubAgentHarnessMeta is gated on translate.FormatAnthropic, mirroring the main-turn gate — OpenAI/Gemini sub-agent dispatches mentioning "plan mode"/"tool schema" now stay on the cheap SubAgentDispatch path instead of escalating to Opus. Regression tests for all three formats.
  • Comments trimmed to the concise-comment rule (applied workweave-bot's six shortening suggestions; removed narration-only blocks); turntype/AGENTS.md and CLAUDE.md kept verbatim-identical.

make precommit and make test pass.

Link to Devin session: https://app.devin.ai/sessions/6f4da5e234fd42cb83560f40a52e6a2b
Requested by: @steventohme

makosblade and others added 2 commits August 18, 2026 13:05
…ct claimed-tool-unavailable

Adds three deterministic turn classifications (harness_meta,
sub_agent_harness_meta, recovery) and a post-routing clamp that escalates
those turns to claude-opus-5 unless the resolved decision is already a
Claude-family TierHigh model. Sub-agent harness turns no longer take the
cheap sub-agent hard-pin; usage-bypass, operator hard pins, /force-model
pins, and loop escalation all outrank the clamp; kill switch is
ROUTER_HARNESS_ESCALATION_ENABLED (default on). The policy sidecar keeps a
stable turn-type vocabulary via TurnType.Base() while telemetry records the
full new values.

Also adds a capture-gated post-stream detector that writes source=auto
rating=down router_feedback rows when a response claims a tool is
unavailable that the request actually declared - persist-only, LRU-deduped
per (session, role, tool).

Motivated by a large agentic session where a sub-agent turn "Load
EnterPlanMode tool schema" was served by a flash-tier model that could not
drive the deferred-tool protocol, silently losing plan mode.

Co-Authored-By: Weave Router <router@workweave.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 9 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/harness_escalation.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/turntype/detect.go Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8aad632. Configure here.

Comment thread internal/proxy/claimed_tool_unavailable.go
Comment thread internal/proxy/service.go
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


Claude finished @devin-ai-integration[bot]'s taskView job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 6 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/router/turntype/detect.go Outdated
Comment thread internal/router/turntype/detect.go Outdated
Comment thread internal/router/turntype/detect.go Outdated
Comment thread internal/router/turntype/detect.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


Claude finished @devin-ai-integration[bot]'s taskView job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 4 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/harness_escalation.go Outdated
Comment thread internal/translate/claudecode_tool_filter.go Outdated
Comment thread internal/translate/lastuser_toolresult.go Outdated
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Applied the first two rounds of comment-length suggestions (commits 7a42241, 7fa2f2d). Politely declining further rounds: the comments now meet the documented convention (root AGENTS.md — concise, why-only), CI is green, and the advisory check is non-converging by design. Happy to revisit if a human reviewer flags a specific comment.

Written by Devin

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


Claude finished @devin-ai-integration[bot]'s taskView job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 6 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/service.go Outdated
Comment thread internal/proxy/turnloop.go Outdated
Comment thread internal/proxy/turnloop.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
Comment thread internal/router/catalog/family.go Outdated
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


Claude finished @devin-ai-integration[bot]'s taskView job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 3 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/router/turntype/harness.go Outdated
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


Claude finished @devin-ai-integration[bot]'s taskView job


  • Gather diff and analyze added comment blocks
  • Flag verbose comment blocks (3+ lines)
  • Post review suggestions

Posted 4 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/turnloop.go Outdated
Comment thread internal/proxy/turnloop.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
Comment thread internal/proxy/claimed_tool_unavailable.go Outdated
@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Claude finished @devin-ai-integration[bot]'s task —— View job


  • Run git diff to analyze added comment blocks
  • Flag verbose 3+ line comment blocks
  • Post review suggestions if found

Posted 3 committable comment-length suggestions on PR #935. All are advisory; none block merge.

@workweave-bot workweave-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Advisory only — comment-length nits. Won't block merge.

Comment thread internal/proxy/claimed_tool_unavailable.go
Comment thread internal/router/turntype/harness.go
Comment thread internal/proxy/turnloop.go
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.

3 participants