Skip to content

fix(spawn): pi profile silently ignores --model from profile config #133

@ruttybob

Description

@ruttybob

Bug

When creating a profile for pi with a --model value, the model is silently ignored during spawn. The resulting command has no --model flag, so pi always uses its default model regardless of profile configuration.

Steps to Reproduce

# Create a pi profile with a specific model
clawteam profile set pi-anthropic \
  --agent pi \
  --model "anthropic/claude-sonnet-4.6"

# Spawn an agent using the profile
clawteam spawn tmux --profile pi-anthropic --team test --task "Do something"

Expected command: pi --model anthropic/claude-sonnet-4.6 -p "..."
Actual command: pi -p "..."--model is missing

Root Cause

In clawteam/spawn/profiles.py, _model_flag() maps agent names to their CLI model flag:

def _model_flag(agent: str) -> str | None:
    if agent in {"claude", "claude-code", "codex", "codex-cli", "gemini", "kimi"}:
        return "--model"
    return None  # ← "pi" is not in the set

apply_profile() calls _model_flag() and only appends --model when the return value is non-None:

if profile.model and not _command_has_model_arg(resolved_command):
    model_flag = _model_flag(agent)
    if model_flag:  # ← False for pi
        resolved_command.extend([model_flag, profile.model])

The pi-coding-agent does support --model (confirmed via pi --help):

--model <pattern>    Model pattern or ID (supports "provider/id" and optional ":<thinking>")

The adapter was added in PR #109 but _model_flag() was overlooked.

Fix

Add "pi" to the _model_flag() agent set, and add explicit return None entries in _base_url_env_var() and _api_key_target_env() for clarity (pi resolves these via --provider and provider-specific env vars).

PR: #132
Branch: fix/pi-profile-model-flag

Test Coverage

3 new tests added:

  • test_apply_profile_pi_model_flag_is_injected — verifies --model is appended
  • test_apply_profile_pi_model_not_duplicated_when_already_present — verifies no double --model
  • test_apply_profile_pi_no_base_url_or_api_key_env_injection — verifies no unintended env var injection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions