Skip to content

fix: animaworks anima set-model should update credential field based on model #168

@animaworks-dev-team

Description

@animaworks-dev-team

Bug Description

animaworks anima set-model <agent> <model> only updates the model field in status.json, but leaves the credential field unchanged. When switching between model providers (e.g., from an Anthropic model to a local OpenAI-compatible model), the agent ends up calling the wrong endpoint.

Steps to Reproduce

# Prerequisite: agent is configured with credential for provider A
animaworks anima set-model <agent-name> openai/<some-model>

# Verify: credential still points to old provider
cat ~/.animaworks/animas/<agent-name>/status.json | grep credential
# → old credential remains unchanged

# Result: agent appears to start, but does not respond
animaworks anima restart <agent-name>
# Sending a message to the agent → no response

Expected Behavior

When set-model is called with a model that belongs to a different provider than the current credential, the command should either:

  1. Automatically update the credential field to match the new model's provider, OR
  2. Warn the user that the credential was not updated and suggest the correct value, OR
  3. Require an explicit --credential flag when switching providers

Actual Behavior

Only the model field is updated in status.json. The credential field retains the old value, causing endpoint mismatch. The agent restarts without errors but fails to process messages silently.

Impact

  • Agents with mismatched model/credential become unresponsive after set-model + restart
  • Silent failure: the process starts normally but all LLM calls fail internally
  • Requires manual status.json editing to recover

Proposed Fix

Option A (Recommended): Add --credential option

animaworks anima set-model <agent> <model> --credential <credential>
  • When --credential is specified, update both model and credential atomically
  • When --credential is omitted but a provider change is detected, emit a warning:
Warning: model provider changed, but --credential was not specified.
  Current credential: anthropic
  Suggested credential for openai/* models: <local-endpoint-credential>
  Re-run with: animaworks anima set-model <agent> <model> --credential <credential>

Option B: Auto-infer credential from model name

Infer the appropriate credential from the model name prefix:

  • openai/* → local OpenAI-compatible endpoint credential
  • claude-* or anthropic/* → Anthropic credential
  • vertex/* → Vertex AI credential

Note: Since multiple credentials may exist for the same provider prefix, Option A (explicit + warning) is safer.

Option C: Startup validation

At agent startup, validate that the model and credential combination is consistent. Log an error and surface a notification when a known mismatch is detected (e.g., an openai/* model with an Anthropic credential).

Recommended Implementation

Implement Option A + Option C:

  1. Add --credential to set-model with provider-change warning when omitted
  2. Add lightweight model/credential compatibility check at agent startup

Workaround

Manually edit status.json to update the credential field after running set-model, then restart the agent:

{
  "model": "openai/some-model",
  "credential": "correct-credential-name"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions