[codex] Add agentic phase events#328
Conversation
Contributor License AgreementThe following contributors need CLA coverage: |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds structured “phase” events to the agent stream and surfaces them in both the TUI and headless outputs to make execution progress more observable.
Changes:
- Introduces
AgentProcessPhase/ToolExecutionPhaseand extendsStreamChunk/ChatEntryto carry phase updates. - Emits phase chunks from the agent and renders them in the app UI and headless text output.
- Adds tests for phase rendering and JSONL emission; updates
.gitignorefor additional local directories.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ui/telegram-turn-ui.ts | Adds buildPhaseEntry helper to create phase ChatEntrys with decoration metadata. |
| src/ui/telegram-turn-ui.test.ts | Adds unit test covering buildPhaseEntry decoration fields. |
| src/ui/app.tsx | Updates review prompt text and renders/appends live phase messages in the UI. |
| src/types/index.ts | Adds phase type aliases and extends ChatEntry + StreamChunk to support phase events. |
| src/headless/output.ts | Renders new phase chunks in text mode and emits phase events via JSONL observer hooks. |
| src/headless/output.test.ts | Adds tests for phase rendering and JSONL phase events. |
| src/agent/agent.ts | Emits process/tool phase chunks and observer callbacks across key points in execution. |
| .gitignore | Ignores additional local agent/playwright/worktree directories. |
Comments suppressed due to low confidence (1)
src/ui/app.tsx:1
- The prompt’s listed ‘Process phases’ does not include
execute_tools, butAgentProcessPhase(and emitted events) includesexecute_tools. To avoid confusing users and to keep the UI/headless phase output aligned with the prompt, either add an explicit ‘Execute tools’ phase to this prompt or remove/renameexecute_toolsso the prompt and emitted phases match.
import type { KeyBinding, KeyEvent, ScrollBoxRenderable, TextareaRenderable } from "@opentui/core";
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case "process_phase": | ||
| case "tool_phase": | ||
| break; |
| @@ -199,6 +202,7 @@ export interface ChatEntry { | |||
| toolCalls?: ToolCall[]; | |||
| toolCall?: ToolCall; | |||
| toolResult?: ToolResult; | |||
| phase?: AgentProcessPhase | ToolExecutionPhase; | |||
| } | |||
| function isReviewRequest(message: string): boolean { | ||
| return /^\s*review\b/i.test(message) || message.includes("Review Report"); | ||
| } |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f4923b9. Configure here.
|
|
||
| function isVerifyRequest(message: string): boolean { | ||
| return /^\s*(\/verify|run a local verification pass)\b/i.test(message); | ||
| } |
There was a problem hiding this comment.
isVerifyRequest never matches the actual verify prompt
Medium Severity
isVerifyRequest checks for messages starting with /verify or "run a local verification pass", but every caller that triggers a verify (/verify slash command, --verify CLI flag) expands the prompt via buildVerifyPrompt() before passing it to processMessage. That expanded prompt starts with "Verify this project locally…", which matches neither pattern. As a result, the "verify" process phase event is never emitted — unlike isReviewRequest, which correctly matches the expanded REVIEW_PROMPT because it starts with "Review".
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f4923b9. Configure here.
|
@jasonkneen thanks for pr, will check! |
|
@jasonkneen this has some issues. Scrollbar in the main view seems to have disappeared as an example. Also the UI is cluttered with tool calls etc. Anyway we could clean the ui up and make it POP? Thanks! |


Summary
/reviewto follow the explicit agentic review loop.Test Plan
bun test src/headless/output.test.ts src/ui/telegram-turn-ui.test.tsbun run typecheckgit diff --checkNotes
bun testwas attempted but is blocked by unrelated existing failures in the broader suite, including missing Vitest helpers such asvi.resetModules,vi.stubGlobal, and duplicatedist/test execution.Note
Medium Risk
Touches core
processMessagestreaming and batch paths plus public stream/observer contracts; behavior is additive but any consumer assuming only legacy chunk types must handle new events.Overview
Adds first-class agent lifecycle and tool execution phases to the streaming pipeline, so clients can show progress beyond raw tool calls.
The agent now emits
process_phasechunks (understand,inspect,execute_tools,review,verify,summarize) andtool_phasechunks (queued,started,finished,failed) in both streaming and batch turns, with matchingProcessMessageObserverhooks (onProcessPhase,onToolPhase).Headless text mode prints dim bullet lines for phases; JSONL mode records
process_phaseandtool_phaseevents (chunks are deduped inconsumeChunkbecause the observer already writes them). The TUI maps these to compactphasechat rows viabuildPhaseEntry/appendLivePhase.The built-in review prompt is reworked around an explicit multi-step agentic loop (understand → inspect → review → verify → summarize) and a findings-first report template.
.gitignoregains a few local agent/tool directories.Reviewed by Cursor Bugbot for commit f4923b9. Configure here.