fix(codex): map last_assistant_message onto Event.TaskDescription - #2070
fix(codex): map last_assistant_message onto Event.TaskDescription#2070suhaanthayyil wants to merge 4 commits into
Conversation
Entire-Checkpoint: 01M0DJJ1MCBA13FMEMTF9HJQ1E
There was a problem hiding this comment.
Pull request overview
This PR improves Codex agent lifecycle event normalization by mapping Codex’s last_assistant_message field onto agent.Event.TaskDescription, allowing downstream lifecycle/strategy code to surface a concise “what just happened” description for both turn-end and subagent-stop events.
Changes:
- Populate
TaskDescriptionfor CodexStop(TurnEnd) events fromlast_assistant_message. - Populate
TaskDescriptionfor CodexSubagentStop(SubagentEnd) events fromlast_assistant_message. - Add/extend tests to cover normal,
null, and whitespace-onlylast_assistant_messagepayloads.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/entire/cli/agent/codex/lifecycle.go | Maps last_assistant_message into Event.TaskDescription for Stop/SubagentStop, with a helper to trim the nullable field. |
| cmd/entire/cli/agent/codex/lifecycle_test.go | Adds assertions and new cases to ensure TaskDescription is set correctly and stays empty for null/blank messages. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…age fixture Address Copilot review: - trimmedLastAssistantMessage now collapses all internal whitespace (newlines/tabs) to single spaces via strings.Fields/Join, not just TrimSpace, so TaskDescription stays single-line when it propagates into commit subjects via strategy.FormatSubagentEndMessage. - Enriched the blank-message Stop fixture with turn_id, permission_mode, and stop_hook_active to match the full stopRaw schema. - Added TestParseHookEvent_Stop_MultilineLastAssistantMessage covering internal newlines/tabs. Entire-Checkpoint: 01M0DMRNA1N6982A0M76BNFD1B
|
Fixed Copilot review comments: SHA: acece6b |
… boundary Codex forwards the whole last_assistant_message into TaskDescription and SaveTaskStep puts its first 60 runes straight into the task checkpoint commit subject, so a reply opening with a credential copied out of tool output became an unredacted Git object. The same text also reached git log carrying JSON-legal NUL, ESC, C1/DEL, and Unicode bidi controls, which strings.Fields preserves and which can make rendered output disagree with what was committed. Add SanitizeSubjectContent as the single boundary for agent-supplied subject text: strip controls, format characters, and invalid UTF-8, fold whitespace runs, then redact. Redaction runs before truncation, since truncating first can cut a secret short of any rule's match and leave the prefix in the subject. Applied to subagent descriptions and TodoWrite content, so every agent is covered rather than Codex alone. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0KQFKAE245R4NBQWZSYCGP2
https://entire.io/gh/entireio/cli/trails/1101
Trail: https://entire.io/gh/entireio/cli/trails/1101
What:
parseTurnEndandparseSubagentStopin the Codex lifecycle parser now copylast_assistant_messageontoagent.Event.TaskDescription.Why / how it helps: Codex sends the agent's own summary of the turn on
StopandSubagentStopaslast_assistant_message, but the parser dropped it on the floor, leavingTaskDescriptionalways empty for Codex events. Cursor's lifecycle parser already populates this field from its owntaskfield, so Codex sessions were the outlier with no description surfaced anywhere downstream (trail summaries, subagent tracking).How: Added a small
trimmedLastAssistantMessagehelper that trims the nullable*stringand returns""for nil or whitespace-only input, so a missing field never becomes a spurious non-empty description. Applied it in bothparseTurnEnd(stop hook) andparseSubagentStop(subagent-stop hook), the only two raw types carryingLastAssistantMessage.Testing:
go test ./cmd/entire/cli/agent/codex/ -count=1— 142 passedTestParseHookEvent_Stop_NullLastAssistantMessageandTestParseHookEvent_Stop_BlankLastAssistantMessage(nil/whitespace edge cases)TestParseHookEvent_Stopto assertevent.TaskDescriptionSubagentStopandSubagentStop_NullTranscriptstests to assertTaskDescriptionpopulates fromlast_assistant_messageand stays empty on nullgit show HEAD --stat)Fixes #2064