fix(cron): honor agentRuntime.id when stamping cron session modelProvider#75840
fix(cron): honor agentRuntime.id when stamping cron session modelProvider#75840vishutdhar wants to merge 1 commit intoopenclaw:mainfrom
Conversation
resolveCronModelSelection derived `provider` purely from the model-string slash-prefix (e.g. "anthropic/claude-opus-4-7" -> "anthropic"), ignoring agents.defaults.agentRuntime.id. For agents whose runtime is a CLI backend (e.g. claude-cli), this stamped modelProvider="anthropic" on the cron session and routed cron-fired turns through the paid Anthropic API instead of the OAuth-backed CLI. The interactive path already consults isCliProvider() in run-executor.ts; this aligns the cron path with the same source of truth. After all model-source overrides resolve, if cfgWithAgentDefaults.agents.defaults.agentRuntime.id is a configured CLI backend, prefer it over the model-string-derived provider. Adds 4 regression tests under "agentRuntime CLI provider stamping" covering positive (claude-cli stamping) and negative (non-CLI runtime, absent runtime) paths.
|
Codex review: needs changes before merge. Summary Reproducibility: yes. Source inspection gives a high-confidence path: configure agentRuntime.id as claude-cli with an Anthropic cron model and current main resolves provider as anthropic, while the PR also needs a mismatched OpenAI override case to avoid stamping claude-cli incorrectly. Next step before merge Security Review findings
Review detailsBest possible solution: Keep the fix focused on cron model selection, but reuse the existing provider/runtime compatibility rule so only compatible CLI runtimes are stamped and unrelated provider overrides remain intact. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence path: configure agentRuntime.id as claude-cli with an Anthropic cron model and current main resolves provider as anthropic, while the PR also needs a mismatched OpenAI override case to avoid stamping claude-cli incorrectly. Is this the best way to solve the issue? No. The PR points at the right cron selection gap, but the implementation should be provider/runtime-pair aware instead of replacing every resolved provider with any configured CLI backend id. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 15bbf4f2f304. |
|
@clawsweeper automerge |
|
🦞🦞
Draft PRs stay fix-only until GitHub marks them ready for review. Pause with Automerge progress:
|
|
ClawSweeper 🐠 reef update Thanks for the work here. ClawSweeper could not write to the source branch, so it opened a replacement PR rather than letting the fix drift. attribution still points back here. Replacement PR: #76319 fish notes: model gpt-5.5, reasoning high; reviewed against 02b6b6c. |
Bug
resolveCronModelSelectionderivesproviderpurely from the model-string slash-prefix (e.g.anthropic/claude-opus-4-7->anthropic), ignoringagents.defaults.agentRuntime.id. For agents whose runtime is a CLI backend (e.g.claude-cli), this stampsmodelProvider="anthropic"on the cron session and routes cron-fired turns through the paid Anthropic API instead of the OAuth-backed Claude CLI.The interactive path already consults
isCliProvider()(src/cron/isolated-agent/run-executor.ts:134); the cron model-selection path never did.Fix
After all model-source overrides resolve, if
cfgWithAgentDefaults.agents.defaults.agentRuntime.idis a configured CLI backend, prefer it over the model-string-derived provider. The model name itself is left untouched (the underlying model is still e.g.claude-opus-4-7); only the provider stamp changes.Diff is +17 lines in
src/cron/isolated-agent/model-selection.ts(one new import, one post-resolution check).Repro / Impact
Local OpenClaw setup with two agents whose
agentRuntime.id="claude-cli"and a cron driving each: cron session entries stampedmodelProvider="anthropic"with the underlying model name, and the cron-fired turns routed through paid API at a small but persistent daily API spend that should have flowed through the user's Claude OAuth subscription. Interactive turns from the same agents routed correctly through the CLI/OAuth path.A workspace-side detector that walks
~/.openclaw/agents/*/sessions/sessions.json, parses session keys matchingagent:<id>:cron:*, and flags any whose parent agent hasagentRuntime.id="claude-cli"butmodelProvider != "claude-cli"confirmed three leaking sessions before the fix and zero after.Tests
Adds 4 cases to
src/cron/isolated-agent.model-formatting.test.tsunder a newagentRuntime CLI provider stampingdescribe block:agentRuntime.idwhen it is a configured CLI backendagentRuntime.idis not a CLI backendVerified the new tests fail without the patch (positive cases) and pass with the patch.
Targeted lane run locally:
pnpm exec node scripts/run-vitest.mjs run --config test/vitest/vitest.cron.config.ts-> 88 files / 769 tests pass. I did not run the fullpnpm build && pnpm check && pnpm testlane in my dev environment; happy to add anything maintainers want.AI assistance disclosure
codex review --base origin/mainlocally; will respond to any GitHub Codex / bot review conversations.