← Back to PRs

#22845: Pass agentDir through cron and followup embedded runs

by seilk open 2026-02-21 18:54 View on GitHub →
size: S
## Summary - Pass `agentDir` into `runEmbeddedPiAgent` in cron and follow-up runner execution paths. - Add focused regression tests for agentDir forwarding. ## Type - [x] Bug fix - [ ] Feature - [ ] Refactor - [ ] Docs - [ ] Chore ## Scope - [x] Targeted bugfix (small, non-breaking) - [ ] Broad behavior change - [ ] New feature surface ## Changes - `src/cron/isolated-agent/run.ts`: pass `agentDir` into `runEmbeddedPiAgent` when running cron jobs. - `src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts`: add regression test asserting `agentDir` is forwarded for cron runs. - `src/auto-reply/reply/followup-runner.ts`: pass `queued.run.agentDir` into `runEmbeddedPiAgent`. - `src/auto-reply/reply/followup-runner.test.ts`: add regression test for the follow-up path. ## Why `runEmbeddedPiAgent` resolves provider credentials from `agentDir` and defaults to `main` when missing. In these paths, the directory was not being passed, causing non-default jobs to potentially use the wrong auth store and fail with provider key errors. ## Security impact - **Low**: The change is additive parameter threading only. - It reduces cross-agent auth cross-usage risk by explicitly using the job/queue-owned agent directory. ## Verification Could not run the test suite in this environment because project dependencies are not installed in this container. - PR scope is limited to auth-path threading plus regression tests. - Recommended command for maintainers: - `pnpm test src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts src/auto-reply/reply/followup-runner.test.ts` ## Human verification - Confirmed local behavioral expectation by tracing run flow around: - `runCronIsolatedAgentTurn` (cron path) - `createFollowupRunner` (queued follow-ups) ## Failure recovery - Revert this PR if any unexpected auth-path behavior is observed; the changes are isolated and can be dropped safely. ## Issue Closes #22842 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR fixes a bug where `agentDir` was resolved but not passed through to `runEmbeddedPiAgent` in two code paths: the followup runner (auto-reply) and the cron isolated-agent runner. In both cases, `agentDir` was already being passed to `runWithModelFallback` but was missing from the inner `runEmbeddedPiAgent` call, meaning embedded agent runs would not respect per-agent directory configuration. - Adds `agentDir: queued.run.agentDir` to the `runEmbeddedPiAgent` call in `src/auto-reply/reply/followup-runner.ts` - Adds `agentDir` to the `runEmbeddedPiAgent` call in `src/cron/isolated-agent/run.ts` - Removes unused `formatXHighModelHint` import from `src/cron/isolated-agent/run.ts` - Adds test coverage for both paths verifying `agentDir` propagation <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it fixes a missing parameter propagation with proper test coverage. - The changes are minimal and focused: two one-line additions passing an already-resolved `agentDir` variable through to `runEmbeddedPiAgent`, one unused import removal, and two well-structured tests. The `agentDir` parameter is already typed as optional in `RunEmbeddedPiAgentParams`, the variable is already in scope at both call sites, and both tests verify correct propagation. No logic changes, no new dependencies, no security implications. - No files require special attention <sub>Last reviewed commit: 732ebc9</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs