Optimize Router Agent Decision-Making and Enhance UI Confirmation Workflows#152
Merged
Conversation
Introduce `add_message`, `add_user_message`, `clear`, and `clear_context` methods on `MessageThread` to encapsulate state changes. This ensures that thread persistence and metadata updates are consistently handled via the `@auto_persist` decorator, rather than relying on direct list or set mutations by callers.
…+insert paste - track terminal text selection to preserve copied content across interactions - add shift+insert keybinding for pasting in the terminal input widget - implement x11 primary selection support via xclip for linux terminal compatibility - integrate textual's app-level clipboard api as a fallback alongside pyperclip
…prompt context Introduces a router_turn_id to track routing iterations and ensure the user's initial request is persisted exactly once. Updates the prompt builder to filter out the request message on subsequent iterations, appending only tool call observations. Adds comprehensive tests for turn tracking and idempotency.
replace cutoff_string utility with a dedicated parse_router_json method that uses raw_decode to correctly parse json containing embedded markdown code blocks. add unit test to verify parsing behavior.
…o prompts - Introduce `prompt_for_yes_no` interface across CLI and TUI wrappers - Refactor command confirmation widgets to support customizable titles and questions - Update AI routing instructions to restrict `/code` usage to large, complex tasks - Implement explicit user confirmation step before executing the `/code` command
Capture the selection on copy button mouse down to prevent losing it when focus changes. Also, fall back to copying all terminal text if no selection is present.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request introduces a series of refinements to the message thread architecture, the router agent's decision-making process, and the user interface. The primary goal is to transition from direct manipulation of thread state to a clean, encapsulated API on the
MessageThreadclass. Additionally, this update optimizes routing logic by establishing a clear policy on when to invoke the heavy/codeagent versus performing lightweight, localized edits directly. It also introduces user confirmation prompts before launching coding agents and improves clipboard integration across terminal and chat interfaces.What This Means for Users
Shift+Insert.A Closer Look at the Changes
Code Refinements & Thread Encapsulation
thread.messagesandthread.contextwith dedicated methods onMessageThread(add_message,add_user_message,clear, andclear_context) to ensure consistent state management and automatic persistence.parse_router_jsonmethod inCommandInterpretationAgentto handle LLM responses containing markdown code blocks inside JSON strings, reducing parsing failures.Router Agent & Input Handler Optimizations
select_command.md) with a strict/codeselection policy, guiding it to use direct tools (likewrite_file) for simple edits and reserve/codefor complex, multi-file tasks.router_turn_idtracking mechanism to record user requests once per routing turn, preventing duplicate user messages from cluttering the conversation history during multi-step tool executions.UI & Confirmation Enhancements
CommandConfirmationWidgetinto an inline yes/no prompt widget capable of displaying custom titles and questions.prompt_for_yes_nointerface toUiWrapperand implemented it across CLI and TUI environments to support interactive user confirmations.Testing
test_message_thread.pyandtest_router_agent.pyto verify thread persistence, idempotent turn recording, and robust JSON parsing.Generated by JrDev AI using google/gemini-3.5-flash