Message models are missing 'timestamp' field
This timestamp field is present in the JSONL file, but the Message types are missing it. Adding it, would be helpful for use cases where the actual Message timestamp is important (ex. displaying a timeline)
I'm happy to submit a PR for this, if there's an agreement this is useful to have
greetings, @danielsiwiec do you mind checking this out? also should I prepare tests? although i did mock it
{
"type": "assistant",
"timestamp": 1734300000123,
"parent_tool_use_id": None,
"message": {
"role": "assistant",
"model": "fake-model",
"content": [
{"type": "text", "text": "hello"}
]
}
}
msg = parse_message(raw)
print(type(msg).__name__)
print("timestamp:", getattr(msg, "timestamp", None))
print("model:", getattr(msg, "model", None))
print("content:", getattr(msg, "content", None))
AssistantMessage timestamp: 1734300000123 model: fake-model content: [TextBlock(text='hello')]
Hi! 👋
I can add the missing timestamp field to Message models.
Analysis
Message models in agent SDK should include timestamp for tracking message timing and sequencing.
Implementation Plan
- Add
timestampfield to Message model (datetime type) - Populate on message creation
- Update serialization/deserialization
- Add tests for timestamp handling
- Update type hints + documentation
Questions
- ISO 8601 format or Unix timestamp?
- Should it be optional (backwards compat) or required?
- Timezone: UTC or preserve original?
Background
Experienced with Anthropic SDK patterns, maintained EGOS v.2 with comprehensive message tracking.
Timeline: 2 days
Happy to implement!
thanks @vikramsingh117 , @enioxt. I already have a PR for this here @ashwin-ant or @dicksontsai - would love a review on this PR 🙏
@ashwin-ant just bumping this up. hopefully this is nothing controversial and is similar to the other PR I contributed before (basically, extending the types coverage over the serialized json structure). thanks in advance!
Hey, we're looking into how to support this. I think the open PRs are not actually correct, since adding timestamps requires updating the CC binary to output timestamps in its messages over stdio (something it doesn't currently do). We'll have more here soon!
@ashwin-ant the current CC binary already outputs "timestamp" per each message (except the SystemMessage). example:
{...,"version":"2.0.19","gitBranch":"","message":{"model":"claude-sonnet-4-5-20250929","id":"msg_bdrk_01V5GhD8qakWV3u9RV23XXfb","type":"message","role":"assistant","content":"..."},"type":"assistant","uuid":"31727d65-53eb-47b3-b843-1b6e1821a534","timestamp":"2025-10-20T10:30:52.256Z"}
That's visible in the JSONL file but it's not actually coming through the stdio pipe at the moment.
gotcha, thanks @ashwin-ant . is there anything I can do to help move this along?