Skip to content

fix(spawn): add pi to profile model flag resolution#132

Open
ruttybob wants to merge 1 commit intoHKUDS:mainfrom
ruttybob:fix/pi-profile-model-flag
Open

fix(spawn): add pi to profile model flag resolution#132
ruttybob wants to merge 1 commit intoHKUDS:mainfrom
ruttybob:fix/pi-profile-model-flag

Conversation

@ruttybob
Copy link
Copy Markdown

Summary

When a profile specifies --agent pi --model X, the model is silently ignored because _model_flag() in profiles.py did not include "pi" in its agent set.

Changes

  • clawteam/spawn/profiles.py — Add "pi" to _model_flag() so --model is appended from profile.model. Add explicit return None entries for pi in _base_url_env_var() and _api_key_target_env() (pi resolves these via --provider and provider-specific env vars, not a single base-url/api-key env).
  • tests/test_profiles.py — Add 3 new tests:
    • 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 pi does not auto-inject env vars

Test Results

All 445 tests pass (2 skipped due to missing mcp module, unrelated to this change):

tests/test_adapters.py ...................                                [  4%]
tests/test_board.py ..............                                       [  7%]
tests/test_cli_commands.py ................                              [ 11%]
tests/test_config.py ..............                                      [ 14%]
tests/test_context.py ..                                                 [ 14%]
tests/test_costs.py ...........                                          [ 17%]
tests/test_fileutil.py ..........                                        [ 19%]
tests/test_gource.py .....                                               [ 20%]
tests/test_identity.py ...............                                   [ 23%]
tests/test_inbox_routing.py ..                                           [ 24%]
tests/test_lifecycle.py .......                                          [ 25%]
tests/test_mailbox.py ..............................                     [ 32%]
tests/test_manager.py .............................                      [ 39%]
tests/test_models.py ..................                                  [ 43%]
tests/test_plan_storage.py .....                                         [ 44%]
tests/test_presets.py ........                                           [ 46%]
tests/test_profiles.py ...........                                       [ 47%]  ← was 8, now 11
tests/test_prompt.py .........                                           [ 49%]
tests/test_registry.py ......................                            [ 54%]
tests/test_runtime_routing.py ..........                                 [ 57%]
tests/test_snapshots.py .....................                            [ 61%]
tests/test_spawn_backends.py .......................................     [ 70%]
tests/test_spawn_cli.py .................                                [ 74%]
tests/test_store.py ..................                                   [ 78%]
tests/test_task_store_locking.py .                                       [ 78%]
tests/test_tasks.py ............................................         [ 88%]
tests/test_templates.py .........................                        [ 94%]
tests/test_timefmt.py ...                                                [ 94%]
tests/test_waiter.py ...................                                 [ 99%]
tests/test_workspace_manager.py .                                        [ 99%]
tests/test_wsh_backend.py ...                                            [100%]

======================= 445 passed in 143.36s ========================

Usage Example

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

# Spawn an agent — --model is now correctly appended
clawteam spawn tmux --profile pi-anthropic --team myteam --task "Implement feature X"
# Results in: pi --model anthropic/claude-sonnet-4.6 -p "..."

- Add "pi" to _model_flag() so --model is injected from profile.model
- Add explicit pi entries in _base_url_env_var() and _api_key_target_env()
  (returning None — pi resolves these via --provider and provider-specific env)
- Add 3 new tests:
  - pi model flag is injected from profile
  - pi model not duplicated when --model already in command
  - pi does not auto-inject base_url or api_key env vars

Fixes a regression where OK Saved profile 'my-pi'
would silently ignore the model because _model_flag() did not include pi.
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