Skip to content

[codex] Add agentic phase events#328

Open
jasonkneen wants to merge 3 commits into
superagent-ai:mainfrom
jasonkneen:codex/agentic-review-phases
Open

[codex] Add agentic phase events#328
jasonkneen wants to merge 3 commits into
superagent-ai:mainfrom
jasonkneen:codex/agentic-review-phases

Conversation

@jasonkneen
Copy link
Copy Markdown

@jasonkneen jasonkneen commented May 30, 2026

Summary

  • Add first-class process and tool phase events to the agent stream.
  • Surface phase events in headless JSONL/text output and compact TUI rows.
  • Update /review to follow the explicit agentic review loop.

Test Plan

  • bun test src/headless/output.test.ts src/ui/telegram-turn-ui.test.ts
  • bun run typecheck
  • git diff --check

Notes

  • Full bun test was attempted but is blocked by unrelated existing failures in the broader suite, including missing Vitest helpers such as vi.resetModules, vi.stubGlobal, and duplicate dist/ test execution.

Note

Medium Risk
Touches core processMessage streaming 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_phase chunks (understand, inspect, execute_tools, review, verify, summarize) and tool_phase chunks (queued, started, finished, failed) in both streaming and batch turns, with matching ProcessMessageObserver hooks (onProcessPhase, onToolPhase).

Headless text mode prints dim bullet lines for phases; JSONL mode records process_phase and tool_phase events (chunks are deduped in consumeChunk because the observer already writes them). The TUI maps these to compact phase chat rows via buildPhaseEntry / 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. .gitignore gains a few local agent/tool directories.

Reviewed by Cursor Bugbot for commit f4923b9. Configure here.

Copilot AI review requested due to automatic review settings May 30, 2026 14:26
@open-cla
Copy link
Copy Markdown

open-cla Bot commented May 30, 2026

Contributor License Agreement

The following contributors need CLA coverage:

Review and sign the CLA

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 / ToolExecutionPhase and extends StreamChunk/ChatEntry to 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 .gitignore for 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, but AgentProcessPhase (and emitted events) includes execute_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/rename execute_tools so 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.

Comment thread src/headless/output.ts
Comment on lines +344 to +346
case "process_phase":
case "tool_phase":
break;
Comment thread src/types/index.ts
Comment on lines 191 to 206
@@ -199,6 +202,7 @@ export interface ChatEntry {
toolCalls?: ToolCall[];
toolCall?: ToolCall;
toolResult?: ToolResult;
phase?: AgentProcessPhase | ToolExecutionPhase;
}
Comment thread src/agent/agent.ts
Comment on lines +2666 to +2668
function isReviewRequest(message: string): boolean {
return /^\s*review\b/i.test(message) || message.includes("Review Report");
}
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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

Comment thread src/agent/agent.ts

function isVerifyRequest(message: string): boolean {
return /^\s*(\/verify|run a local verification pass)\b/i.test(message);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f4923b9. Configure here.

@homanp
Copy link
Copy Markdown
Contributor

homanp commented Jun 1, 2026

@jasonkneen thanks for pr, will check!

@homanp
Copy link
Copy Markdown
Contributor

homanp commented Jun 1, 2026

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants