Skip to content

fix(agents): restore resolveAgentRuntimeOrThrow body — unblock agent dispatch (#2408)#2423

Merged
alexey-pelykh merged 1 commit intomainfrom
fix/resolve-agent-runtime-or-throw-2408
Apr 19, 2026
Merged

fix(agents): restore resolveAgentRuntimeOrThrow body — unblock agent dispatch (#2408)#2423
alexey-pelykh merged 1 commit intomainfrom
fix/resolve-agent-runtime-or-throw-2408

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

Fixes #2408. src/agents/agent-scope.ts:491-493 was 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, /agent CLI, and cron isolated-agent runs. Users saw:

⚠️ Agent failed before reply: resolveAgentRuntimeOrThrow is not available in RemoteClaw fork.

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 to agents.defaults.runtime.

Changes

  • src/agents/agent-scope.ts:491-502 — replaced throwing stub with real body. Return type string (not literal union) matches resolveAgentRuntime'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 — added describe("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 a string is 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 at run.auth-retry.test.ts:50 and run.channel-bridge.test.ts:71 remain valid — they return "claude", which is compatible with the new () => string signature).
  • pnpm test → 795 files / 6996 tests / 3 skipped / 0 failed.

Acceptance criteria (from #2408)

  • resolveAgentRuntimeOrThrow(cfg, agentId) returns the runtime string when resolveAgentRuntime resolves a value.
  • Throws with a clear message naming the agent id and pointing to agents.defaults.runtime when no runtime configured.
  • Regression test asserts both paths (configured → return; missing → throw).
  • pnpm check passes (format + typecheck + lint).
  • pnpm test passes (existing call-site mocks remain valid).
  • Header comment at agent-scope.ts:437 relocated.
  • N/A — LIVE smoke (LIVE=1 pnpm test:live): CLAUDE.md § PR Submission Workflow requires LIVE only for src/middleware/ changes. This PR touches src/agents/agent-scope.ts only — LIVE smoke is not in scope for this change.

Test plan

  • Unit tests pass locally
  • Type-check + lint clean
  • CI green on PR

…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>
@alexey-pelykh alexey-pelykh enabled auto-merge (squash) April 19, 2026 07:54
@alexey-pelykh alexey-pelykh merged commit d4a01b9 into main Apr 19, 2026
12 checks passed
@alexey-pelykh alexey-pelykh deleted the fix/resolve-agent-runtime-or-throw-2408 branch April 19, 2026 07:58
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.

fix(agents): restore resolveAgentRuntimeOrThrow body — regression stub crashed every agent dispatch

1 participant