fix(codex): map last_assistant_message onto Event.TaskDescription - #2070
fix(codex): map last_assistant_message onto Event.TaskDescription#2070suhaanthayyil wants to merge 12 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
SanitizeSubjectContent now redacts before bounding input, and task descriptions are sanitized at launch, completion, and materialization so secrets do not reach task.json metadata. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0TTAS4JXS4JPNRZ87E9BV5N
Factory AI session titles are raw model output; sanitize before they reach UpsertCompletedTaskRecord and task.json metadata. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0TTKSHYGEGZK2EBBKH3SPGS
Truncate to maxSubjectRedactionInput before redact.String so whole model replies cannot force unbounded regex/entropy work on hook paths. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0TXKAHHBNHTN3W5734ZV6NW
Truncating before redact let secrets straddling the 4096-rune cap leak a prefix into task.json and commit subjects. Inputs over the window now return a fixed omitted label after control stripping. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0VA4AG4RS189AM1C71GGD9P
Check the 4096-rune cap before control stripping so padding tricks cannot shrink past the window, and omit instead of truncating redacted output. Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0WB2VJAT5WTEM7RYPX4Q0V2
Co-authored-by: Cursor <cursoragent@cursor.com> Entire-Checkpoint: 01M0X8JH1FS6GTFQE6QM91TG7V
https://entire.io/gh/entireio/cli/trails/1101
Scope (updated)
This branch establishes a shared cross-agent sanitization boundary before text reaches Git or checkpoint metadata:
Verification: go test ./cmd/entire/cli/strategy/... plus lifecycle/checkpoint tests for TaskDescription persistence.