~kris/9p

llm9p

27f32368fc5ace37f82cc9c0768e62406ae7ef5a — pdfinn 6 months ago bad7a7b
fix(llmfs): expand model aliases and update default model ID

Add a modelAliases map in session_settings.go so that short names
written to /n/llm/N/model are expanded to full Anthropic model IDs:

  haiku  → claude-haiku-4-5-20251001
  sonnet → claude-sonnet-4-6
  opus   → claude-opus-4-6

This fixes spawn subagents which write short names like "haiku" to the
model file — the Anthropic API rejects bare aliases as invalid model IDs.

Also update the default model from the stale claude-sonnet-4-20250514
to claude-sonnet-4-6 to match current API availability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 files changed, 18 insertions(+), 2 deletions(-)

M internal/llm/session.go
M internal/llmfs/session_settings.go
M internal/llm/session.go => internal/llm/session.go +1 -1
@@ 21,7 21,7 @@ type SessionDefaults struct {
// DefaultSessionDefaults returns sensible defaults for new sessions.
func DefaultSessionDefaults() SessionDefaults {
	return SessionDefaults{
		Model:          "claude-sonnet-4-20250514",
		Model:          "claude-sonnet-4-6",
		Temperature:    0.7,
		SystemPrompt:   "",
		ThinkingTokens: 0,

M internal/llmfs/session_settings.go => internal/llmfs/session_settings.go +17 -1
@@ 40,6 40,22 @@ func (f *SessionModelFile) Read(p []byte, offset int64) (int, error) {
	return copy(p, content[offset:]), nil
}

// modelAliases maps short convenience names to full Anthropic model IDs.
var modelAliases = map[string]string{
	"haiku":  "claude-haiku-4-5-20251001",
	"sonnet": "claude-sonnet-4-6",
	"opus":   "claude-opus-4-6",
}

// resolveModel expands a short alias to its full model ID, or returns the
// input unchanged if it is already a full ID (or unknown).
func resolveModel(name string) string {
	if full, ok := modelAliases[strings.ToLower(name)]; ok {
		return full
	}
	return name
}

// Write sets the model name.
func (f *SessionModelFile) Write(p []byte, offset int64) (int, error) {
	session := f.sm.Get(f.id)


@@ 47,7 63,7 @@ func (f *SessionModelFile) Write(p []byte, offset int64) (int, error) {
		return 0, protocol.ErrNotFound
	}

	model := strings.TrimSpace(string(p))
	model := resolveModel(strings.TrimSpace(string(p)))
	if model != "" {
		session.SetModel(model)
	}