fix(agents): restore resolveAgentRuntimeOrThrow body — unblock agent dispatch (#2408)#2423
Merged
alexey-pelykh merged 1 commit intomainfrom Apr 19, 2026
Merged
Conversation
…dispatch (#2408) The sync from upstream v2026.3.8 (#2360) replaced the function body with an unconditional-throw stub, crashing every agent dispatch across Slack auto-reply, the /agent CLI, and cron isolated-agent runs. Users saw "⚠️ Agent failed before reply: resolveAgentRuntimeOrThrow is not available in RemoteClaw fork". Restore the prescribed semantics: delegate to the non-throwing sibling resolveAgentRuntime; throw only when no runtime is configured, with a message that names the agent id and points to agents.defaults.runtime. Return type is string (not the literal union) to avoid over-constraining fork-native runtime names, matching resolveAgentRuntime's return shape. All 3 live callers already express this contract; no call-site changes required. Existing call-site mocks return "claude" — they remain semantically valid. Header comment at agent-scope.ts:437 updated from "Upstream-compat stubs (gutted in fork)" to "Fork-native runtime & auth resolvers" since every function in the section is fork-native. Regression test covers both paths: configured → return, missing → throw, with assertions on the throw-message format. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2408.
src/agents/agent-scope.ts:491-493was an unconditional-throw stub introduced by the sync in #2360 (upstream v2026.3.7 → v2026.3.8). It crashed every agent dispatch across three call sites — Slack auto-reply,/agentCLI, and cron isolated-agent runs. Users saw:This PR restores the prescribed semantics: delegate to the non-throwing sibling
resolveAgentRuntime, throw only when no runtime is configured, with a message that names the agent id and points toagents.defaults.runtime.Changes
src/agents/agent-scope.ts:491-502— replaced throwing stub with real body. Return typestring(not literal union) matchesresolveAgentRuntime's shape and avoids over-constraining fork-native runtime names.src/agents/agent-scope.ts:437— header comment changed from"Upstream-compat stubs (gutted in fork)"to"Fork-native runtime & auth resolvers". Every function in this section is fork-native; the old header was already misleading and becomes actively wrong after this fix.src/agents/agent-scope.test.ts— addeddescribe("resolveAgentRuntimeOrThrow")with 5 regression cases covering both paths (configured → return, missing → throw) and throw-message format.No call-site changes required — all 3 live callers already pass
(cfg, agentId)positionally and use the return where astringis expected.Verification
pnpm check→ format / tsgo / lint all clean.pnpm vitest run src/agents/agent-scope.test.ts -t "resolveAgentRuntimeOrThrow"→ 5/5 passed.pnpm vitest run --config vitest.unit.config.ts src/cron/isolated-agent/run.auth-retry.test.ts src/cron/isolated-agent/run.channel-bridge.test.ts→ 27/27 passed (existing mocks atrun.auth-retry.test.ts:50andrun.channel-bridge.test.ts:71remain valid — they return"claude", which is compatible with the new() => stringsignature).pnpm test→ 795 files / 6996 tests / 3 skipped / 0 failed.Acceptance criteria (from #2408)
resolveAgentRuntimeOrThrow(cfg, agentId)returns the runtime string whenresolveAgentRuntimeresolves a value.agents.defaults.runtimewhen no runtime configured.pnpm checkpasses (format + typecheck + lint).pnpm testpasses (existing call-site mocks remain valid).agent-scope.ts:437relocated.LIVE=1 pnpm test:live): CLAUDE.md § PR Submission Workflow requires LIVE only forsrc/middleware/changes. This PR touchessrc/agents/agent-scope.tsonly — LIVE smoke is not in scope for this change.Test plan