From e1631fcab6a8f593d497f7542a30b575b37b5e4e Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sun, 21 Dec 2025 16:36:43 +0000 Subject: [PATCH] feat: capture actual model from Claude SDK init message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update handleSystemMessage() in claude-agent.ts to read the actual model from the SDK's init message (message.model) instead of just echoing back the configured model. This gives us the real runtime model that the SDK selected. Also invalidates cached runtime info when the model is updated to ensure getRuntimeInfo() returns the new value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- packages/server/src/server/agent/providers/claude-agent.ts | 6 ++++++ plan.md | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/server/src/server/agent/providers/claude-agent.ts b/packages/server/src/server/agent/providers/claude-agent.ts index 6a6e9c59e..39b2f7304 100644 --- a/packages/server/src/server/agent/providers/claude-agent.ts +++ b/packages/server/src/server/agent/providers/claude-agent.ts @@ -873,6 +873,12 @@ class ClaudeAgentSession implements AgentSession { this.availableModes = DEFAULT_MODES; this.currentMode = message.permissionMode; this.persistence = null; + // Capture actual model from SDK init message (not just the configured model) + if (message.model) { + this.lastOptionsModel = message.model; + // Invalidate cached runtime info so it picks up the new model + this.cachedRuntimeInfo = null; + } } private convertUsage(message: SDKResultMessage): AgentUsage | undefined { diff --git a/plan.md b/plan.md index bb52d0d88..4c82686f9 100644 --- a/plan.md +++ b/plan.md @@ -89,10 +89,11 @@ Hard requirement: We must get the actual runtime model, not just echo back the r - Fix: Update `handleSystemMessage()` to capture `message.model` as `lastOptionsModel` - Alternatively: Extract model name from `modelUsage` keys in `SDKResultMessage` -- [ ] **Implement**: Capture actual model from Claude SDK init message. +- [x] **Implement**: Capture actual model from Claude SDK init message. - In `handleSystemMessage()`, set `this.lastOptionsModel = message.model` - This gives us the actual model the SDK selected (not just our config) - Simpler than parsing modelUsage, same result + - **Done (2025-12-21 13:25)**: Updated `handleSystemMessage()` in `claude-agent.ts:868-882` to capture `message.model` from the SDK init message and invalidate cached runtime info. Typecheck passes. - [ ] **Test**: Verify current Codex runtime model detection works. - Create a Codex agent with default model