docs: add LLM metrics migration guide for Python SDK v3#1570
docs: add LLM metrics migration guide for Python SDK v3#1570
Conversation
Document the changes to LLM metrics access in v3, including: - New usage field on operation responses (act, observe, extract, execute) - Metric name mapping (input_tokens, output_tokens, inference_time_ms) - New fields for cached_input_tokens and reasoning_tokens - Updated quick reference and troubleshooting section Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
Greptile SummaryDocuments how LLM metrics access changed in Python SDK v3, where metrics moved from a separate Key Changes
The documentation is well-structured, uses correct Python syntax with snake_case, and provides clear migration guidance for users transitioning from v2 to v3. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as Developer
participant Client as Stagehand Client
participant API as Stagehand API
participant LLM as LLM Service
Note over User,LLM: LLM Metrics Migration (v2 → v3)
rect rgb(240, 240, 240)
Note right of User: Old SDK (v2) Flow
User->>Client: stagehand.metrics
Client-->>User: Metrics from replay endpoint
end
rect rgb(220, 255, 220)
Note right of User: New SDK (v3) Flow
User->>Client: client.sessions.act(...)
Client->>API: POST /sessions/{id}/act
API->>LLM: Process act request
LLM-->>API: Response + usage metrics
API-->>Client: Response with usage field
Client-->>User: response.data.result.usage
Note over User: Access metrics directly:<br/>- input_tokens<br/>- output_tokens<br/>- inference_time_ms<br/>- cached_input_tokens<br/>- reasoning_tokens
end
|
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Document the changes to LLM metrics access in Stagehand Python SDK v3, including how metrics are now accessed via the
usagefield on operation responses instead of a separate replay endpoint.Changes
Test plan
🤖 Generated with Claude Code
Summary by cubic
Adds a migration guide for LLM metrics in Python SDK v3, moving metrics from the old replay endpoint to the usage field on operation responses. Includes code examples and updates to help teams upgrade quickly.
Written for commit a8be963. Summary will update on new commits.