Skip to content

fix: fallback on retryable model errors - #1

Open
tomllt wants to merge 4 commits into
mainfrom
fix/retryable-model-fallback
Open

fix: fallback on retryable model errors#1
tomllt wants to merge 4 commits into
mainfrom
fix/retryable-model-fallback

Conversation

@tomllt

@tomllt tomllt commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • wire retryable agent errors into configured model fallback switching
  • allow fallback chains to select a backup model on the same provider after 429/quota backoff
  • add regression tests for 502 no-body failures and 429 same-provider token-plan exhaustion

Root cause

  • retryable provider errors were only retried locally and never invoked FallbackResolver
  • FallbackResolver marked the current provider as exhausted before scanning the chain, which incorrectly blocked backup models on the same provider

Verification

  • pnpm --filter @gsd/agent-core run build
  • pnpm --filter @gsd/agent-core test

tomllt pushed a commit that referenced this pull request Jul 8, 2026
…n-gsd#818 cross-cutting (open-gsd#1129)

## TL;DR

**What:** Cross-cutting parent-workspace fixes found while completing
open-gsd#818: a `/gsd doctor` probe that validates declared child repos, and a
validation warning for the `mode:team` + `workspace.mode:parent`
footgun.
**Why:** Doctor reported "no problems" for a typo'd child-repo path, and
team+parent silently degraded push/PR to the root repo.
**How:** New `checkWorkspaceRepositoryHealth` doctor probe (no-op for
project mode) + a cross-axis preferences warning pointing at ADR-044.

## What

- **#1 Doctor probe** (`doctor.ts`, `doctor-types.ts`) —
`checkWorkspaceRepositoryHealth`: for parent-mode projects, flags
`workspace_repo_path_missing` (declared path absent on disk) and
`workspace_repo_not_a_repo` (path exists but isn't a git repo at its
**own** root). The registry only checked paths stay inside the project
root — never existence or git-ness — so `path: frontned` (typo) built
cleanly and doctor reported clean. The git-repo check compares against
`git rev-parse --show-toplevel` (realpath-normalized) so a plain dir
nested in the parent repo can't pass via the enclosing parent's `.git`.
- **open-gsd#2 Validation warning** (`preferences-validation.ts`) — `mode:team`
+ `workspace.mode:parent` now warns that team branch-push/PR resolves at
the project root and won't push child repos, pointing at ADR-044.
Previously this combination was silently broken (push/PR root-only).
- **open-gsd#6 Regression guard** — a new doctor test asserts the common layout
(parent is a plain folder holding child git repos, not itself a git
repo) is handled gracefully.

## Why

These are cross-cutting concerns the issue's 6 gaps didn't enumerate:
- Doctor is the natural place users diagnose misconfiguration; a silent
typo is the worst failure mode.
- The two `mode` axes (team vs parent-workspace) both touch git/push but
were never cross-checked, so the combination silently lost team mode's
push value.

## How / Verification

- `tsc --noEmit --project tsconfig.extensions.json` — clean.
- `pnpm run verify:fast` — all fast-gates passed.
- `doctor-workspace.test.ts` — 5/5 pass (missing path, not-a-repo, valid
repos, project-mode no-op, non-git parent).
- `preferences.test.ts` — 102/102 pass (2 new: team+parent warns; team
alone doesn't).
- `doctor-empty-worktree.test.ts` — 3/3 pass (existing doctor probes
unaffected).

### Scope
This is a focused diagnostics/validation bundle. Two related findings
are handled separately:
- **open-gsd#5** (`/gsd status` per-repo signal) — its own follow-up.
- **open-gsd#3 / open-gsd#4** (runtime repo write-guard; parallel orchestration) —
design-level / RFC-blocked; documented in ADR-044, not blind-coded here.

AI-assisted; no AI credited as author.

Change type: `feat` / `test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are additive diagnostics, docs, and a CI checkout tweak; no
auth, data migration, or runtime execution-path changes beyond read-only
git probes during doctor.
> 
> **Overview**
> Adds **parent-workspace diagnostics** so misconfigured child repos are
visible instead of a clean doctor run, plus a **merged-preference
warning** when team mode and parent workspace are combined.
> 
> **`/gsd doctor`** (parent `workspace.mode` only) now validates each
declared child repo: missing paths raise `workspace_repo_path_missing`;
paths that are not a git root (including dirs that only inherit the
parent’s `.git`) raise `workspace_repo_not_a_repo`, using `git rev-parse
--show-toplevel` with realpath normalization and `GIT_NO_PROMPT_ENV`.
> 
> **Preferences** emit a cross-axis warning when effective settings are
`mode: team` and `workspace.mode: parent` (root-only push/PR; ADR-044),
via `crossAxisPreferenceWarnings` on validation, effective load, and
doctor/preflight diagnostics.
> 
> User docs cover the new doctor codes and the team+parent footgun.
**CI** checkouts detach `refs/checkout-ref` after fetch instead of
`$GITHUB_SHA`. New tests cover workspace doctor cases and preference
merge behavior.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a8945df. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

<!-- codesmith:footer -->
---
<a
href="https://app.blacksmith.sh/open-gsd/codesmith/gsd-pi/pr/1129"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img
alt="View with Codesmith"
src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a>
<sup>Need help on this PR? Tag <code>/codesmith</code> with what you
need. Autofix is enabled.</sup>

<!-- codesmith:autofix:enabled -->
<!-- /codesmith:footer -->
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