Skip to content

fix(core): preserve workspace cwd on CLI provider retries#918

Merged
christso merged 3 commits intomainfrom
fix/912-cli-provider-retry-cwd
Apr 2, 2026
Merged

fix(core): preserve workspace cwd on CLI provider retries#918
christso merged 3 commits intomainfrom
fix/912-cli-provider-retry-cwd

Conversation

@christso
Copy link
Copy Markdown
Collaborator

@christso christso commented Apr 2, 2026

Closes #912

Problem

When a CLI provider command fails and is retried, the invokeBatch() method always used this.config.cwd (which defaults to the eval file directory), ignoring the per-request request.cwd workspace override passed by the orchestrator.

Fix

  • CliProvider.invokeBatch(): Use requests[0]?.cwd ?? this.config.cwd so workspace path overrides are respected in batch mode, matching the behavior of invoke().
  • Test coverage: Added tests verifying:
    • Orchestrator retry loop preserves sharedWorkspacePath as request.cwd across retry attempts
    • invoke() prefers request.cwd over config.cwd
    • invoke() falls back to config.cwd when request.cwd is undefined
    • invokeBatch() prefers first request's cwd over config.cwd

Test plan

  • New unit test: orchestrator preserves workspace cwd across retry attempts
  • New unit tests: CLI provider cwd override in invoke and invokeBatch
  • All 365 existing tests pass
  • Pre-push hooks pass (build, typecheck, lint, test, validate)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 2, 2026

Deploying agentv with  Cloudflare Pages  Cloudflare Pages

Latest commit: aaa22a8
Status: ✅  Deploy successful!
Preview URL: https://738094b2.agentv.pages.dev
Branch Preview URL: https://fix-912-cli-provider-retry-c.agentv.pages.dev

View logs

christso and others added 2 commits April 2, 2026 12:01
- Fix CliProvider.invokeBatch() to use per-request cwd override
  (request.cwd) instead of always using this.config.cwd. The first
  request's cwd takes priority, falling back to config.cwd.
- Add test verifying orchestrator retry loop preserves workspace cwd
  across retry attempts via sharedWorkspacePath → request.cwd chain.
- Add tests for invoke/invokeBatch cwd override vs config.cwd fallback.

Closes #912

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address code review feedback:
- Replace raw.cwd references with effectiveCwd in all 3 invokeBatch
  response objects (success, error, fallback)
- Add batch cwd invariant comment
- Add invokeBatch fallback test for undefined request.cwd

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@christso christso marked this pull request as ready for review April 2, 2026 12:27
@christso christso merged commit b40f2a9 into main Apr 2, 2026
4 checks passed
@christso christso deleted the fix/912-cli-provider-retry-cwd branch April 2, 2026 12:27
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.

bug: CLI provider retries don't preserve workspace cwd

1 participant