Skip to content

Enable and render basic tool calling for the TUI#13283

Open
harryalbert wants to merge 5 commits into
masterfrom
harry/tui-agent-tool-calling
Open

Enable and render basic tool calling for the TUI#13283
harryalbert wants to merge 5 commits into
masterfrom
harry/tui-agent-tool-calling

Conversation

@harryalbert

@harryalbert harryalbert commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

This PR gets basic tool calling working, and renders these tool calls in the blocklist (in a very basic way, for now). Most of this PR is just wiring, as, because we reused the terminal model, manager, blocklist ai models, etc., tool calling is basically the same for the TUI and the GUI (which is great).

For shell commands, there's a bit of extra wiring required, but it's still pretty minimal. I had the agent draw up an ascii diagram for the shell command execution flow as it's a bit hard to trace in the code:

┌──────────────────────────────────────────────────────────────┐
│ 1. Shared shell-tool executor  (surface-agnostic)            │
│    BlocklistAIActionModel → shell_command_executor           │
│    emits ShellCommandExecutorEvent::ExecuteCommand           │
└──────────────────────────────────────────────────────────────┘
                            │
                            │  subscribe_to_model(&shell_command_executor)
                            ▼
┌───────────────────────────────────────────────────────────────┐
│ 2. TUI surface                                                │
│    crates/warp_tui/src/terminal_session_view.rs               │
│    TuiTerminalSessionView::handle_shell_command_executor_event│
│    builds ExecuteCommandEvent, then                           │
│    ctx.emit(TuiTerminalSessionEvent::ExecuteCommand)          │
└───────────────────────────────────────────────────────────────┘
                            │
                            │  PtyIntentEvent::pty_intent()
                            │  → PtyIntent::ExecuteCommand
                            ▼
┌──────────────────────────────────────────────────────────────┐
│ 3. PTY-intent bridge  (generic, all surfaces)                │
│    app/src/terminal/writeable_pty/terminal_manager_util.rs   │
│    wire_up_pty_controller_with_surface()                     │
│    matches PtyIntent::ExecuteCommand                         │
└──────────────────────────────────────────────────────────────┘
                            │
                            │  controller.update(...)
                            ▼
┌──────────────────────────────────────────────────────────────┐
│ 4. PTY controller                                            │
│    PtyController::write_command() → writes to the PTY        │
└──────────────────────────────────────────────────────────────┘

Wiring set up once at construction:
  app/src/terminal/local_tty/terminal_manager.rs:377
  wire_up_pty_controller_with_surface(&pty_controller, &surface, …)
  surface = TuiTerminalSessionView

We don't implement file diffs in this PR, as that will require some extra work (the file diff executor relies on the GUI's diff view directly right now, so there's some extraction that needs to be done). Marked as TODO for now and will submit a PR above this one in the stack to get that working.

The last change is that, for GUI ai block rendering, we now walk through the messages in the given block's exchange and render them as various sub-sections (i.e. input, agent output, tool calls, etc.). This sets us up well to reach parity with the GUI ai block, as there's a clear place to add rendering for thinking, todo creation, etc.

Testing

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

https://www.loom.com/share/4cdd488c6ace49caa4a94485cfe96e08

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

harryalbert commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@harryalbert harryalbert force-pushed the harry/tui-agent-tool-calling branch from e556dca to 032f1a5 Compare July 1, 2026 18:26
Base automatically changed from harry/tui-transcript-view to master July 1, 2026 19:02
@harryalbert harryalbert force-pushed the harry/tui-agent-tool-calling branch from 032f1a5 to 5693b52 Compare July 1, 2026 19:32
@harryalbert harryalbert mentioned this pull request Jul 1, 2026
4 tasks
@harryalbert harryalbert changed the title write tech spec Enable basic tool calling for the TUI Jul 1, 2026
@harryalbert harryalbert changed the title Enable basic tool calling for the TUI Enable and renderbasic tool calling for the TUI Jul 1, 2026
@harryalbert harryalbert changed the title Enable and renderbasic tool calling for the TUI Enable and render basic tool calling for the TUI Jul 1, 2026
@harryalbert harryalbert marked this pull request as ready for review July 1, 2026 20:53
@harryalbert harryalbert requested a review from kevinyang372 July 1, 2026 20:53
@oz-for-oss

oz-for-oss Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@harryalbert

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot 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.

Overview

This PR wires basic TUI tool-call rendering and shell-command execution through the shared Agent Mode action model. The description includes visual evidence, and spec_context.md did not provide approved spec context to validate against.

Concerns

  • TUI conversations are now forced into RunToCompletion even outside sandboxed/autonomous execution, which bypasses the user's configured tool permissions for non-denylisted commands and other actions.

Security

  • RunToCompletion short-circuits several permission checks, so enabling it by default for local TUI sessions can let model-emitted shell commands and other tool actions run without the user's approval settings.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread crates/warp_tui/src/conversation_selection.rs
let text_color =
Fill::from(ThemeFill::from(theme.terminal_colors().bright.black)).into();
Box::new(
TuiContainer::new(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use .finish() here?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants