Skip to content

Feature request: Built-in Fallback Model for Subagents #4

Description

@marcinkardas

Problem

When a subagent's primary model fails (rate limit, overloaded, API error), the entire subagent crashes and propagates the error to the main session. This requires manual intervention and disrupts the workflow.

Common scenario:

  • GPT-5.5 rate limit reached → reviewer fails → main session must handle manually

Proposed Solution

Add fallback_model field to agent .md frontmatter:

---
name: my-reviewer
model: openai-codex/gpt-5.5
fallback_model: anthropic/claude-sonnet-4-6
thinking: high
---

When the primary model fails with a retryable error (429, 529, overloaded_error), pi-subagents-lite automatically retries with the fallback model.

Benefits

  • Resilient workflows: Multi-agent pipelines continue running despite API issues
  • Cost optimization: Use cheaper primary model, fallback to reliable secondary
  • Developer experience: No manual intervention needed for transient failures

Implementation Notes

Retry logic should:

  • Only retry on retryable errors (rate limit, overloaded, timeout)
  • Preserve all other parameters (thinking level, max turns, tools, etc)
  • Log the fallback attempt for debugging
  • NOT retry on non-retryable errors (invalid API key, model not found, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestwontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions