← Back to PRs

#16303: fix: apply cron payload.model override to session entry and pass auth profile

by superlowburn open 2026-02-14 16:07 View on GitHub →
stale size: XS
## Summary Fixes #14401 — Model override in cron jobs is ignored when using Claude Max subscription tokens. **Root cause:** The cron isolated-agent path (`runCronIsolatedAgentTurn`) resolves the correct model via `runWithModelFallback`, but: 1. Never applies the resolved model override to the session entry (unlike sub-agents which call `applyModelOverrideToSessionEntry`) 2. Never passes `authProfileId` to `runEmbeddedPiAgent` (unlike the sub-agent path in `agent.ts`) 3. `resolveCronSession` doesn't copy `authProfileOverride` fields from existing session entries This means downstream code that reads model/auth config from the session entry gets stale values, causing the override to be silently ignored. **Fix (3 files):** - `src/cron/isolated-agent/run.ts` — import `applyModelOverrideToSessionEntry`, apply it when the resolved model differs from the default, and pass `authProfileId`/`authProfileIdSource` to `runEmbeddedPiAgent` - `src/cron/isolated-agent/session.ts` — copy `authProfileOverride` and `authProfileOverrideSource` from existing session entries - `src/cron/isolated-agent/session.test.ts` — add test for auth profile preservation ## Test plan - [x] All 102 cron tests pass (`npx vitest run src/cron/`) - [x] New test verifies `authProfileOverride` fields are preserved across session resets - [ ] Manual: configure a cron job with `modelOverride` set to a subscription-backed model, verify the override is applied 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixed model override in cron jobs being ignored when using subscription tokens by ensuring the resolved model and auth profile are properly applied to the session entry and passed through to `runEmbeddedPiAgent`. **Key changes:** - `resolveCronSession` now preserves `authProfileOverride` and `authProfileOverrideSource` fields from existing sessions - Added call to `applyModelOverrideToSessionEntry` after resolving the cron session to update the session entry with the resolved model - Pass `authProfileId` and `authProfileIdSource` to `runEmbeddedPiAgent` (matching sub-agent behavior in `agent.ts:413-414`) - New test verifies auth profile fields are preserved across session resets The fix ensures downstream code reading from the session entry sees the correct model and auth configuration. <h3>Confidence Score: 5/5</h3> - Safe to merge with high confidence - The implementation correctly mirrors the sub-agent behavior, properly preserves auth profile overrides that were previously being deleted, includes test coverage, and all 102 cron tests pass. The previous review concern about auth profile deletion has been addressed in commit 29607276a. - No files require special attention <sub>Last reviewed commit: 2960727</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs