feat: enhance CurrentRequest interface with prompt timing and tracking#3958
feat: enhance CurrentRequest interface with prompt timing and tracking#3958TylerLeonhardt wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request enhances the CurrentRequest interface in the Claude Code Agent to track prompt timing metrics for performance monitoring. The changes add two new tracking fields to capture when prompts are yielded to the SDK and when the first response token is received, enabling time-to-first-token and total request duration measurements through trace logging.
Changes:
- Added
promptYieldedAtandfirstTokenReceivedfields to theCurrentRequestinterface for timing tracking - Initialize timing fields when creating current request instances
- Log time-to-first-token when the first message arrives from the SDK
- Log total request duration when result messages are received
| promptYieldedAt: number; | ||
| firstTokenReceived: boolean; |
There was a problem hiding this comment.
The new fields promptYieldedAt and firstTokenReceived are not marked as readonly, which is inconsistent with the existing fields in the CurrentRequest interface (stream, toolInvocationToken, token, yieldRequested). Since these fields are mutated after initialization, they should not be marked as readonly. However, this creates an inconsistency in the interface design pattern.
Consider whether these tracking fields should be separated into a different structure or if the pattern is acceptable for mutable tracking state. The existing pattern suggests all CurrentRequest fields should be readonly references to the original request, but these new fields are tracking state that changes during request processing.
No description provided.