Skip to content

fix(codex): map last_assistant_message onto Event.TaskDescription - #2070

Open
suhaanthayyil wants to merge 4 commits into
mainfrom
fix/track-2064
Open

fix(codex): map last_assistant_message onto Event.TaskDescription#2070
suhaanthayyil wants to merge 4 commits into
mainfrom
fix/track-2064

Conversation

@suhaanthayyil

@suhaanthayyil suhaanthayyil commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/1101

Trail: https://entire.io/gh/entireio/cli/trails/1101

What: parseTurnEnd and parseSubagentStop in the Codex lifecycle parser now copy last_assistant_message onto agent.Event.TaskDescription.

Why / how it helps: Codex sends the agent's own summary of the turn on Stop and SubagentStop as last_assistant_message, but the parser dropped it on the floor, leaving TaskDescription always empty for Codex events. Cursor's lifecycle parser already populates this field from its own task field, so Codex sessions were the outlier with no description surfaced anywhere downstream (trail summaries, subagent tracking).

How: Added a small trimmedLastAssistantMessage helper that trims the nullable *string and returns "" for nil or whitespace-only input, so a missing field never becomes a spurious non-empty description. Applied it in both parseTurnEnd (stop hook) and parseSubagentStop (subagent-stop hook), the only two raw types carrying LastAssistantMessage.

Testing:

  • go test ./cmd/entire/cli/agent/codex/ -count=1 — 142 passed
  • Added TestParseHookEvent_Stop_NullLastAssistantMessage and TestParseHookEvent_Stop_BlankLastAssistantMessage (nil/whitespace edge cases)
  • Extended TestParseHookEvent_Stop to assert event.TaskDescription
  • Extended the existing SubagentStop and SubagentStop_NullTranscripts tests to assert TaskDescription populates from last_assistant_message and stays empty on null
  • Verified on the committed tree (git show HEAD --stat)

Fixes #2064

Entire-Checkpoint: 01M0DJJ1MCBA13FMEMTF9HJQ1E
Copilot AI lite review requested due to automatic review settings August 19, 2026 17:56
@suhaanthayyil
suhaanthayyil marked this pull request as ready for review August 19, 2026 17:57
@suhaanthayyil
suhaanthayyil requested a review from a team as a code owner August 19, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TaskDescription for Codex Stop (TurnEnd) events from last_assistant_message.
  • Populate TaskDescription for Codex SubagentStop (SubagentEnd) events from last_assistant_message.
  • Add/extend tests to cover normal, null, and whitespace-only last_assistant_message payloads.

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.

Comment thread cmd/entire/cli/agent/codex/lifecycle_test.go
Comment thread cmd/entire/cli/agent/codex/lifecycle.go
…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
@suhaanthayyil

Copy link
Copy Markdown
Contributor Author

Fixed Copilot review comments: trimmedLastAssistantMessage now collapses all internal whitespace (strings.Fields/Join) so TaskDescription stays single-line before hitting commit subjects; enriched the blank-message Stop fixture with turn_id/permission_mode/stop_hook_active to match the full stopRaw schema; added a multiline-message test. gofmt clean, codex tests pass (143 passed).

SHA: acece6b

suhaanthayyil and others added 2 commits August 19, 2026 14:51
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Codex last_assistant_message is parsed then discarded on Stop/SubagentStop

2 participants