Skip to content

improvement(executor): run the Agent block on the shared model-fallback walk - #9982

Merged
waleedlatif1 merged 2 commits into
stagingfrom
improvement/agent-shared-fallback-loop
Nov 13, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
improvement/agent-shared-fallback-loop

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • One shared fallback walk. Router, Evaluator and the Agent block now walk their model candidates through walkModelCandidates in executor/utils/model-fallbacks.ts. Before, the Agent kept its own copy of the walk. The walk owns:
    • the candidate order;
    • holding fallbacks until the final try;
    • de-duplication;
    • skipping unusable fallbacks (provider, permission, family);
    • resolving the saved credential once per call for candidates on the primary's provider;
    • the stop rules;
    • the block-log modelFallbacks record.
  • Callers supply three pieces: an attempt, an optional prepare (a fallback that throws there is skipped, not counted as a failure), and skip/fallback log callbacks. executeModelRequestWithFallbacks is now a thin wrapper.
  • The Agent keeps its own behavior in its callbacks:
    • Per-provider file hydration moves into prepare, which runs against the settled registries without mutating ctx. A fallback whose provider can't take the attached files is skipped.
    • Stream priming, the deep-research hold, the evaluation-model refusal and the log text are unchanged.
    • The manual save/restore of the error registries is gone. A fallback swaps ctx to the settled registries once, when its attempt starts.
  • No behavior change for any of the three blocks.

Type of Change

  • Improvement (refactor)

Testing

  • The existing agent, router, evaluator and model-fallback-request tests pass unchanged; they serve as the behavior spec.
  • New tests:
    • A primary failure followed by an attachment-skipped fallback rethrows the primary's error, redacted against the failed attempt's registries.
    • A later fallback runs from the settled registries.
    • The walk doesn't count a prepare skip as a failure, and rethrows the last real error when only skips remain.
  • Red proofs:
    • Removing the registry swap or the skip semantics fails the new tests.
    • The new Agent tests also pass against the previous Agent loop, which shows behavior is preserved.
  • Runs: 1,894 executor and lib/workflows/blocks tests pass. bun run lint, check-block-registry.ts origin/staging, check:test-patterns, check:comment-hygiene, check:explicit-any, check:boundaries, check:utils, check:file-names and check:tool-registry-boundary --check pass. Type-check and the full suite run in CI.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 13, 2026 4:59am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The Agent, Router, and Evaluator now share walkModelCandidates.

  • Agent, Router, and Evaluator now try fallback models through one shared walk.

No actionable issues were found. This review checked source code and test assertions; it did not run the tests.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Agent, Router, or Evaluator] --> B[walkModelCandidates]
  B --> C[Try primary]
  C --> D{Result}
  D -->|Success| E[Record failed models and return]
  D -->|Stop or final failure| F[Rethrow last error]
  D -->|Retryable failure| G[Check next fallback]
  G --> H{Provider and preparation usable?}
  H -->|No| G
  H -->|Yes| I[Try fallback]
  I --> D
Loading

Reviews (2) · Last reviewed commit: "fix(executor): type the agent test block..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 force-pushed the improvement/agent-shared-fallback-loop branch from 22d525c to 57c67da Compare November 13, 2026 04:54
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

This branch was successfully deployed

1 active deployment
Preview — 57c67dad Deployed Nov 13, 2026 by vercel[bot]
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.

1 participant