feat: capture actual model from Claude SDK init message

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 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2025-12-21 16:36:43 +00:00
parent 845a2120ee
commit e1631fcab6
2 changed files with 8 additions and 1 deletions

View File

@@ -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 {

View File

@@ -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