Skip to content

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

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

fix(codex): map last_assistant_message onto Event.TaskDescription#2070
suhaanthayyil wants to merge 12 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

Scope (updated)

This branch establishes a shared cross-agent sanitization boundary before text reaches Git or checkpoint metadata:

  • Codex lifecycle: map last_assistant_message to Event.TaskDescription
  • SanitizeSubjectContent: redact secrets, strip unsafe controls; fail closed when input exceeds the 4096-rune window
  • Persistence: lifecycle launch/completion, manual-commit condensation, checkpoint task.json, Git commit subjects
  • Agents: Codex primary; any path through strategy.SanitizeSubjectContent

Verification: go test ./cmd/entire/cli/strategy/... plus lifecycle/checkpoint tests for TaskDescription persistence.

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 10 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
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
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.

2 participants