Skip to content

Conversation

@wtfsayo
Copy link

@wtfsayo wtfsayo commented Jan 4, 2026

Summary

  • Add a new "wrap up" feature (W key) that gracefully requests an agent to finish its current work and report findings
  • Provides a middle ground between letting an agent run indefinitely and hard-stopping it with ESC
  • Agent receives an urgent message to conclude within 3-5 iterations and call agent_finish or finish_scan

Changes

  • agents_graph_actions.py: Add wrap_up_agent() function that sends an urgent wrap-up instruction
  • tui.py: Add WrapUpAgentScreen modal, W keybinding, and action handlers
  • tui_styles.tcss: Add amber/warning styling for the wrap-up dialog

Test plan

  • Run strix --target ./app and start a scan
  • Select an agent in the tree
  • Press W to trigger wrap-up dialog
  • Confirm and verify agent receives the wrap-up message
  • Verify agent attempts to summarize and finish gracefully
  • Press F1 to confirm help shows new keybinding

Add a new "wrap up" feature that allows users to gracefully request
an agent to finish its current work and report findings, instead of
hard-stopping with ESC.

Changes:
- Add wrap_up_agent() function in agents_graph_actions.py that sends
  an urgent message instructing the agent to conclude within 3-5 iterations
- Add WrapUpAgentScreen modal dialog in tui.py with amber/warning styling
- Add 'W' keyboard binding to trigger wrap-up on selected agent
- Update help screen to show new keybinding
- Add CSS styles for the wrap-up dialog

This provides a middle ground between letting an agent run indefinitely
and hard-stopping it - the agent can summarize findings and properly
report back to its parent via agent_finish or finish_scan.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 4, 2026

Greptile Summary

This PR implements a graceful wrap-up feature for agents, providing users with a middle ground between letting an agent run indefinitely (no action) and hard-stopping it (ESC key). The feature adds a new W keybinding that triggers a modal dialog allowing users to request agents finish their current work gracefully and report findings.

Key Changes:

  • Agent Control: New wrap_up_agent() function in agents_graph_actions.py sends an XML-formatted URGENT instruction to agents, giving them 3-5 iterations to complete work and call agent_finish/finish_scan
  • UI Layer: New WrapUpAgentScreen modal class with proper event handling, validation, and action handlers that mirrors the existing StopAgentScreen pattern
  • Keybinding: Added W key binding with proper priority handling and help text documentation
  • Styling: Comprehensive amber/warning color (#f59e0b) styling for visual distinction from the red stop action

Architecture & Integration:
The implementation properly integrates with the existing agent control architecture:

  • Uses the same message queue system (_agent_messages) that agents check in each iteration
  • Respects agent state (validates running/waiting status before wrap-up)
  • Resumes waiting agents so they can process the wrap-up instruction immediately
  • Follows established code patterns for modal screens, validation, and action handlers

Design Rationale:
The wrap-up feature addresses a real UX need—users can request agents stop cleanly without losing findings, which are properly reported via agent_finish/finish_scan mechanisms. This contrasts with hard stop which immediately cancels execution and may lose telemetry.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk. Implementation is well-designed, follows established patterns, and properly integrates with existing agent control mechanisms.
  • The PR scores 5/5 confidence because: (1) All three files show clean, well-structured additions with no logic errors or edge case bugs; (2) The wrap_up_agent() function properly validates agent existence, checks terminal states, creates well-formatted instructions, and integrates with the message queue system correctly; (3) The TUI implementation mirrors existing patterns (StopAgentScreen) reducing risk of UI bugs; (4) Proper validation logic ensures wrap-up can only be triggered on running/waiting agents; (5) The feature gracefully degrades—agents that are already finished simply receive a success response; (6) No breaking changes to existing APIs or dependencies; (7) Styling is consistent with the codebase's existing aesthetic patterns; (8) The feature addresses a documented user need (middle ground between indefinite run and hard stop) as stated in the PR description; (9) All keybindings are properly registered with correct priority handling; (10) Error handling follows the codebase's established patterns with try-except blocks and logging.
  • No files require special attention. All changes are additions that follow existing patterns and integrate cleanly with the codebase.

Important Files Changed

Filename Overview
strix/tools/agents_graph/agents_graph_actions.py Added wrap_up_agent() function (lines 533-606) that sends an XML wrap-up instruction to an agent and resumes it if waiting. Implementation correctly follows existing patterns, handles edge cases (already finished agents), uses proper message structure, and integrates with agent state management. Mirrors the structure of stop_agent() but uses graceful messaging instead of cancellation. No issues found.
strix/interface/tui.py Added WrapUpAgentScreen modal class (lines 221-271) with proper event handling, keybinding (lines 329), and action handlers (action_wrap_up_selected_agent, _validate_agent_for_wrap_up, action_confirm_wrap_up_agent at lines 1285-1346). Help text updated to document new keybinding. Implementation mirrors StopAgentScreen pattern but with warning variant styling. Validation correctly checks for running/waiting status. No issues found.
strix/interface/assets/tui_styles.tcss Added comprehensive styling for WrapUpAgentScreen (lines 599-667) using amber/warning color (#f59e0b) to visually distinguish from red stop action. Includes dialog, title, description, buttons, and hover states. Styling follows existing patterns and is properly integrated after the StopAgentScreen styles. No issues found.

Sequence Diagram

sequenceDiagram
    actor User
    participant TUI as Textual UI
    participant TUIApp as StrixTUIApp
    participant AgentGraph as agents_graph_actions
    participant AgentState as Agent State
    participant Agent as Agent Loop

    User->>TUI: Press W key
    TUI->>TUIApp: action_wrap_up_selected_agent()
    TUIApp->>TUIApp: _validate_agent_for_wrap_up()
    TUIApp->>TUI: Show WrapUpAgentScreen Modal
    User->>TUI: Click "Yes"
    TUI->>TUIApp: action_confirm_wrap_up_agent(agent_id)
    TUIApp->>AgentGraph: wrap_up_agent(agent_id)
    
    rect rgb(100, 200, 100)
        note right of AgentGraph: Check agent status
        AgentGraph->>AgentGraph: Verify agent is running/waiting
    end
    
    rect rgb(100, 150, 200)
        note right of AgentGraph: Send wrap-up message
        AgentGraph->>AgentGraph: Create wrap-up XML message
        AgentGraph->>AgentGraph: Append to _agent_messages[agent_id]
    end
    
    rect rgb(200, 150, 100)
        note right of AgentGraph: Resume if waiting
        AgentGraph->>AgentState: is_waiting_for_input()?
        alt Agent is waiting
            AgentGraph->>AgentState: resume_from_waiting()
        end
    end
    
    AgentGraph-->>TUIApp: Return success status
    TUIApp->>TUI: Log completion message
    
    rect rgb(150, 150, 200)
        note right of Agent: Agent processes wrap-up
        Agent->>Agent: Next iteration starts
        Agent->>Agent: _check_agent_messages()
        Agent->>Agent: Finds wrap-up message
        Agent->>Agent: Processes URGENT instruction
        Agent->>Agent: Summarizes findings
        Agent->>Agent: Calls agent_finish or finish_scan
    end
Loading

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.

1 participant