dostuff 0.2.9__tar.gz → 0.2.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dostuff-0.2.9 → dostuff-0.2.10}/PKG-INFO +94 -2
- {dostuff-0.2.9 → dostuff-0.2.10}/README.md +93 -1
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/loop.py +88 -9
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/cli_tui.py +200 -19
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/config.py +4 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/constants.py +2 -0
- dostuff-0.2.10/dostuff/helpers/agent/steering.py +107 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/templates/config.example.yaml +3 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/PKG-INFO +94 -2
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/SOURCES.txt +2 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/pyproject.toml +1 -1
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_config_memory_mcp.py +15 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_loop.py +411 -0
- dostuff-0.2.10/tests/test_steering.py +121 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_tui.py +847 -3
- {dostuff-0.2.9 → dostuff-0.2.10}/LICENSE +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/__main__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/call_agent.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/instructions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/permissions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/run_tool.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/adapter.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/definitions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/fork.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/prompt.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/registry.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/agent/subagents/run.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/cli.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/headless.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/append_step.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/consume_stream.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/context_usage.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/environment_context.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/file_mentions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/get_model_token_limit.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/load_identity.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/load_project_instructions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/loop_check_cancelled.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/loop_emit.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/manage_context.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/model_cost.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/notices.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/pastes.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/quick_memory.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/side_question.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/slash_suggestion.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/agent/tool_output.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/dispatch.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/events.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/load_hooks.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/run_hook.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/hooks/trust.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/mcp/load_mcp_config.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/mcp/mcp_oauth.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/mcp/server_config.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/mcp/token_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/memory/export_session.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/memory/resolve_memory_operation.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/memory/shell_step.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/models/add_model_entry.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/models/list_models.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/models/opencode.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/skills/custom_commands.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/skills/discover_skills.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/skills/skill_command.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/tools/diff.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/tools/generate_tool_schema.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/tools/project_root.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/tools/resolve_safe_path.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/ask_answers.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/doctor.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/emit.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/prompt_history.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/terminal_signals.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/helpers/ui/tools_listing.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/checkpoints.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/exceptions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/mcp/mcp_client.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/mcp/mcp_client_registration_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/mcp/mcp_tool_registry_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/chroma.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/episodic_memory_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/semantic_memory_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/session_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/stores.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/memory/types.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/model.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/tracing.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/lib/worktree.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/memory/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/setup_wizard.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/skills.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/templates/env.example +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/__init__.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/agent.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/ask_user.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/bash/bash_command.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/bash/bash_output.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/bash/jobs.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/bash/kill_shell.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/create_agent_type.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/definitions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/files/delete_file.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/files/edit_file.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/files/list_files.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/files/read_file.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/files/write_file.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/get_current_datetime.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/mcp/call_mcp_tool.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/mcp/get_mcp_tool_details.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/mcp/search_mcp_tools.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/memory/save_episode.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/memory/save_memory.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/names.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/search/glob.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/search/grep.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/search/walk.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/send_message.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/settings.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/stop_agent.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/todo_write.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/web_fetch.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff/tools/web_search.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/dependency_links.txt +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/entry_points.txt +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/requires.txt +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/dostuff.egg-info/top_level.txt +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/setup.cfg +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_ask_user.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_bash_command.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_checkpoints_todos_caching.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_cli_commands.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_create_agent_type.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_file_mentions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_file_tools.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_hooks.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_jobs.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_mcp_e2e.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_mcp_oauth.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_opencode.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_optional_memory_and_instructions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_pastes.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_permissions.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_roadmap_021.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_session_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_settings_tools.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_setup_wizard.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_side_question.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_side_question_litellm.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_skill_command.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_skills_discovery.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_slash_suggestion.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagent.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagents_background.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagents_fork.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagents_run.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagents_store.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_subagents_types.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_terminal_signals.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_tool_schemas.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_tools_listing.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_web_fetch.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_web_search.py +0 -0
- {dostuff-0.2.9 → dostuff-0.2.10}/tests/test_worktree.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dostuff
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.10
|
|
4
4
|
Summary: DoStuff - a terminal coding agent for any LLM: TUI and headless mode, permissions, MCP, skills, web tools, sessions and git worktrees
|
|
5
5
|
Author-email: Varun Kumawat <varunkumawatleap2@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -85,6 +85,7 @@ DoStuff is a terminal AI agent that runs anywhere `pip` runs. It gives you a ful
|
|
|
85
85
|
- **Coding tools** — `read_file` (line numbers, offset/limit), `edit_file` (exact replacement), `write_file`, `grep`, `glob`, `list_files`, `delete_file`, `bash_command`, `web_fetch` (read a URL as text), `web_search` (free, no API key)
|
|
86
86
|
- **`ask_user`** — the agent asks you a real question — up to 4, with 2–4 options each, multi-select and a free-text "Other" — instead of guessing; the answers come back to it as one result and stay readable in `/resume`. See [Asking the user](#asking-the-user)
|
|
87
87
|
- **`/btw` side questions** — ask about the conversation while a turn runs (or idle) without stopping or queuing it: one model call, no tools run, answered in a panel above the input and never added to the history; `f` hands the question to a background agent that can check it with tools. See [Side questions](#side-questions-btw)
|
|
88
|
+
- **Mid-turn steering (`/steer`)** — send a correction to the turn that is running and the model reads it at the next tool boundary instead of waiting for the turn; plain messages steer by default, and `ui.mid_turn_messages: queue` batches them after the turn instead. See [Mid-turn steering](#mid-turn-steering-steer)
|
|
88
89
|
- **Permission layer** — mutating tool calls ask for approval (allow once / always this session / deny with a note); read-only shell commands run without asking; modes `ask` / `allowlist` / `auto`; `/undo` reverts the agent's file changes
|
|
89
90
|
- **Hooks** — shell commands on `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart` and `SubagentStop` that can block a tool call or prompt, feed a formatter's output back to the model, or keep the turn going; Claude Code's hook I/O contract, and project hooks run only once you trust them. See [Hooks](#hooks)
|
|
90
91
|
- **Background jobs** — `bash_command(run_in_background=true)` starts dev servers, watchers and long test runs as jobs the agent reads with `bash_output` (`wait_for` a ready line) and stops with `kill_shell`; it hears when one ends. `Ctrl+B` moves a running command to the background, `/jobs` lists them, and none outlives the session. See [Background jobs](#background-jobs)
|
|
@@ -244,6 +245,7 @@ In the TUI:
|
|
|
244
245
|
| `/permissions [mode]` | Show or change the permission mode for this session (`ask`, `allowlist`, `auto`, `plan`) |
|
|
245
246
|
| `/copy` | Copy the model's last answer to the clipboard |
|
|
246
247
|
| `/btw <question>` | Ask a side question about the conversation, even while a turn runs: answered in a panel above the input, without tools, never added to the history. See [Side questions](#side-questions-btw) |
|
|
248
|
+
| `/steer <message>` | Send a correction to the running turn: the model reads it at the next tool boundary and carries on, without the turn ending. See [Mid-turn steering](#mid-turn-steering-steer) |
|
|
247
249
|
| `/notifications [on\|off\|bell\|osc9]` | Turn turn-finished / approval notifications on or off for this session (default from `ui.notifications`) |
|
|
248
250
|
| `/model [<provider/model>] [--active]` | Pick a model: your saved ones (`models:` in config.yaml) first, then "More <provider> models…" for each provider's list (type to filter; Enter on no match uses what you typed). A model that isn't saved yet is added to `~/.dostuff/config.yaml`. A plain `/model` switch lasts only for this session; add `--active` (e.g. `/model --active`, or `/model anthropic/claude-sonnet-5-5 --active`) to make it the default that new sessions start with |
|
|
249
251
|
| `/config [mcp] [project]` | Edit a settings file right in the TUI: pick `config.yaml` or the MCP servers, user (`~/.dostuff`) or project (`./.dostuff`), or name one (`/config mcp project`). `Ctrl+S` checks the file, saves it and applies it without a restart (an invalid file stays open with the error); `Esc` closes, twice if there are unsaved changes. A new file starts with every option commented out. `.env` files aren't offered |
|
|
@@ -278,7 +280,8 @@ In the TUI:
|
|
|
278
280
|
- **Status bar** — `cwd • model • permission mode • context usage %` by default; `help`, `session`, `tokens` and `cost` can be added. Choose and order the items with `ui.status_bar` in `config.yaml`; when the terminal is too narrow (or zoomed in), long items are shortened and the least important dropped (help, session, cwd, tokens, cost, model, context, mode) instead of being cut off
|
|
279
281
|
- **Shells** — while background jobs run, a `⚙ 2 shells` item sits at the end of the status bar whatever `ui.status_bar` says. Click it (or press `↓` in an empty input) to list the session's jobs with when each started and how long it has run, and click it again to close the list; pick one (click or Enter) to see its last 8 lines of output and log path in the same small panel, refresh them, or stop it
|
|
280
282
|
- **Loading** — bold `Working...` with a live elapsed timer and queued-prompt count, or streamed thoughts displayed live
|
|
281
|
-
- **Queued prompts** — prompts
|
|
283
|
+
- **Queued prompts** — prompts that have to wait for the turn sit above the input, one row each, and run in order: skill and custom commands in both modes, plain messages with `ui.mid_turn_messages: queue`. Click the list (or `/queue`) to pick one and edit it (back into the input), run it next or remove it, or clear them all (`/queue clear`). `Esc` cancels the turn and moves the queued prompts back into the input instead of running them
|
|
284
|
+
- **Steering messages** — `/steer <message>` (and every plain message by default; `ui.mid_turn_messages: queue` makes them wait instead) waits for the next tool boundary instead of the end of the turn: the bar leads with `→ N for the agent · read at the next tool boundary`, `/queue` lists them first with Edit / Remove (and *Send now* turns a queued prompt into one), and `Esc` puts a pending one back in the input ahead of the queue. See [Mid-turn steering](#mid-turn-steering-steer)
|
|
282
285
|
- **Terminal title** — the tab / window title shows the run status: `⏳ dostuff · <folder>` while working, `✋` while an approval waits, `✓` when done; the old title comes back on exit. `ui.terminal_title: false` turns it off
|
|
283
286
|
- **Notifications** (off by default) — `ui.notifications: bell` (terminal bell) or `osc9` (desktop notification in iTerm2, WezTerm, Ghostty, kitty …) when a turn finishes or an approval is waiting, if it took longer than `ui.notify_after_seconds` (30) or the terminal is in the background. `/notifications` switches it per session
|
|
284
287
|
|
|
@@ -511,6 +514,90 @@ no `/btw` (only skills and custom commands run there), so `/btw` in a `-p` promp
|
|
|
511
514
|
|
|
512
515
|
---
|
|
513
516
|
|
|
517
|
+
## Mid-turn steering (`/steer`)
|
|
518
|
+
|
|
519
|
+
A message typed while a turn runs normally waits its turn: it joins the queue and runs as its own prompt when the
|
|
520
|
+
current one ends. `/steer <message>` sends a **correction** instead — the model reads it at the next tool boundary and
|
|
521
|
+
carries on with it, without the turn ending and without anything being interrupted:
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
> /steer actually target ./dostuff, not the repo root
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
It lands in the transcript as a user message right after the tool output it was reacting to — where the model read it
|
|
528
|
+
— and the next model call sees it as the newest user message. A final answer that arrives while a correction is still
|
|
529
|
+
waiting does not end the turn: the model reads it and redoes or extends the answer. That check runs before the `Stop`
|
|
530
|
+
hooks, so they see the answer that really ends the turn.
|
|
531
|
+
|
|
532
|
+
What the model reads is framed, not bare: the stored user step is your text wrapped in two fixed lines —
|
|
533
|
+
`The user sent a new message while you were working:` above it, `Address the message above, then continue the task
|
|
534
|
+
you were working on.` below. The loop has no notion of "the task", only the history, so without that instruction a
|
|
535
|
+
standalone question tends to be answered with a final response and the turn ends with the interrupted work left
|
|
536
|
+
mid-flight; Claude Code wraps mid-turn messages the same way. Everything you *see* stays raw — the transcript line,
|
|
537
|
+
Esc-to-restore, and what a leftover re-runs — the frame reaches only the model, plus the stored transcript that
|
|
538
|
+
`/resume` replays.
|
|
539
|
+
|
|
540
|
+
### Two modes
|
|
541
|
+
|
|
542
|
+
`ui.mid_turn_messages` in `config.yaml` decides what a **plain** message does while a turn runs (default `steer`):
|
|
543
|
+
|
|
544
|
+
| Submitted | `queue` | `steer` (default) |
|
|
545
|
+
|---|---|---|
|
|
546
|
+
| Plain message | waits in the queue, runs after the turn | steering: read at the next tool boundary |
|
|
547
|
+
| `/steer <message>` | steering | steering |
|
|
548
|
+
| `/<skill> args`, custom command | waits in the queue | waits in the queue |
|
|
549
|
+
| `/btw`, `/queue`, `/jobs`, … | run now | run now |
|
|
550
|
+
| `/clear`, `/resume`, `/model`, … | refused while a turn runs | refused while a turn runs |
|
|
551
|
+
| `!command` | refused while a turn runs | refused while a turn runs |
|
|
552
|
+
| `#note` (quick memory) | run now | run now |
|
|
553
|
+
|
|
554
|
+
`steer` is the default because it is Claude Code's behaviour: a correction is read now, at the next tool boundary,
|
|
555
|
+
instead of after the turn. `queue` stays one key away for anyone who prefers batching — three instructions typed in a
|
|
556
|
+
row run as three prompts while you are away, and a queued message is never read mid-task when you meant "next".
|
|
557
|
+
`/steer` works in both modes, and with no turn running it is
|
|
558
|
+
an ordinary prompt (it starts a turn), so the habit is never an error. Skills and custom commands stay in the queue in
|
|
559
|
+
both modes: a skill is a turn's prompt, not a correction.
|
|
560
|
+
|
|
561
|
+
### What you see
|
|
562
|
+
|
|
563
|
+
- **On submit** the input clears and the bar above it leads with the steering group, `→ 1 for the agent · read at the next tool boundary`, above the usual `N queued · click or /queue …` rows; the loader counts them separately, `· 1 steering · 2 queued`.
|
|
564
|
+
- **`/queue`** lists the steering messages first, each marked `→`, with *Edit* and *Remove* (once the loop has read
|
|
565
|
+
one, the picker says "That message was already read."), and every queued prompt gained *Send now (at the next tool
|
|
566
|
+
boundary)*, which turns it into a correction.
|
|
567
|
+
- **Attachments are prepared in order**: `@mentions` are expanded and pastes resolved right after you send, in the
|
|
568
|
+
order you sent them, so a message holding a big file never jumps ahead of the one after it. The `Attached …` lines
|
|
569
|
+
show as they finish, as for a prompt.
|
|
570
|
+
- **Hooks and the sandbox still apply**: `UserPromptSubmit` runs for each correction at the boundary, so a hook can
|
|
571
|
+
block it — it is shown like a blocked prompt and never reaches the model — or add context for this turn, written as a
|
|
572
|
+
note right before the correction (the system prompt never changes mid-turn, so the prompt cache holds); a preparation
|
|
573
|
+
failure is reported instead of half-delivered.
|
|
574
|
+
|
|
575
|
+
### Latency, and `Ctrl+B`
|
|
576
|
+
|
|
577
|
+
Delivery waits for the tool call in flight; nothing is interrupted to deliver sooner, so a two-minute `bash_command`
|
|
578
|
+
delays a correction two minutes. While a message waits behind a running command the bar says why —
|
|
579
|
+
`waiting for a running command · Ctrl+B to background it` — and `Ctrl+B` moves the command (or a foreground subagent)
|
|
580
|
+
to the background, which returns the call to the loop at once: the message is read at the next boundary while the
|
|
581
|
+
command keeps running. `Esc` remains the way to stop.
|
|
582
|
+
|
|
583
|
+
### Leftovers
|
|
584
|
+
|
|
585
|
+
A correction can outlive its turn — sent after the final answer's last check, still being prepared, the turn hit the
|
|
586
|
+
iteration cap, the model call failed, or you pressed `Esc`. Nothing is lost:
|
|
587
|
+
|
|
588
|
+
- **Cancelled** (`Esc`) — the raw text goes back into the input **ahead of** the queued prompts: stopping the work
|
|
589
|
+
includes the corrections to it.
|
|
590
|
+
- **Otherwise** — it runs next: `1 message arrived after the turn ended; running it next`, then it is re-prepared from
|
|
591
|
+
what you typed and runs as a normal turn.
|
|
592
|
+
|
|
593
|
+
Either way the text you typed is written to the history exactly once — whether the model read it mid-turn or it ran as
|
|
594
|
+
the next turn.
|
|
595
|
+
|
|
596
|
+
`dostuff -p` has no `/steer` (only skills and custom commands run there), so a `/steer` line in a `-p` prompt is
|
|
597
|
+
ordinary text for the model.
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
514
601
|
## Subagents
|
|
515
602
|
|
|
516
603
|
A subagent is a separate agent with its own context, system prompt and tools. The main agent hands it a task with the
|
|
@@ -853,6 +940,11 @@ permissions:
|
|
|
853
940
|
mode: ask # ask | allowlist | auto | plan
|
|
854
941
|
allow: []
|
|
855
942
|
|
|
943
|
+
ui:
|
|
944
|
+
mid_turn_messages: steer # steer (default): a plain message sent while a turn runs is read by the model at
|
|
945
|
+
# the next tool boundary, inside the running turn | queue: it waits and runs after
|
|
946
|
+
# the turn. /steer sends one either way (see Mid-turn steering)
|
|
947
|
+
|
|
856
948
|
agents: # see Subagents
|
|
857
949
|
max_iterations: 100 # model calls per run; default: loop.max_iterations (older: loop.subagent_max_iterations)
|
|
858
950
|
max_concurrent: 4
|
|
@@ -37,6 +37,7 @@ DoStuff is a terminal AI agent that runs anywhere `pip` runs. It gives you a ful
|
|
|
37
37
|
- **Coding tools** — `read_file` (line numbers, offset/limit), `edit_file` (exact replacement), `write_file`, `grep`, `glob`, `list_files`, `delete_file`, `bash_command`, `web_fetch` (read a URL as text), `web_search` (free, no API key)
|
|
38
38
|
- **`ask_user`** — the agent asks you a real question — up to 4, with 2–4 options each, multi-select and a free-text "Other" — instead of guessing; the answers come back to it as one result and stay readable in `/resume`. See [Asking the user](#asking-the-user)
|
|
39
39
|
- **`/btw` side questions** — ask about the conversation while a turn runs (or idle) without stopping or queuing it: one model call, no tools run, answered in a panel above the input and never added to the history; `f` hands the question to a background agent that can check it with tools. See [Side questions](#side-questions-btw)
|
|
40
|
+
- **Mid-turn steering (`/steer`)** — send a correction to the turn that is running and the model reads it at the next tool boundary instead of waiting for the turn; plain messages steer by default, and `ui.mid_turn_messages: queue` batches them after the turn instead. See [Mid-turn steering](#mid-turn-steering-steer)
|
|
40
41
|
- **Permission layer** — mutating tool calls ask for approval (allow once / always this session / deny with a note); read-only shell commands run without asking; modes `ask` / `allowlist` / `auto`; `/undo` reverts the agent's file changes
|
|
41
42
|
- **Hooks** — shell commands on `SessionStart`, `UserPromptSubmit`, `PreToolUse`, `PostToolUse`, `Stop`, `SubagentStart` and `SubagentStop` that can block a tool call or prompt, feed a formatter's output back to the model, or keep the turn going; Claude Code's hook I/O contract, and project hooks run only once you trust them. See [Hooks](#hooks)
|
|
42
43
|
- **Background jobs** — `bash_command(run_in_background=true)` starts dev servers, watchers and long test runs as jobs the agent reads with `bash_output` (`wait_for` a ready line) and stops with `kill_shell`; it hears when one ends. `Ctrl+B` moves a running command to the background, `/jobs` lists them, and none outlives the session. See [Background jobs](#background-jobs)
|
|
@@ -196,6 +197,7 @@ In the TUI:
|
|
|
196
197
|
| `/permissions [mode]` | Show or change the permission mode for this session (`ask`, `allowlist`, `auto`, `plan`) |
|
|
197
198
|
| `/copy` | Copy the model's last answer to the clipboard |
|
|
198
199
|
| `/btw <question>` | Ask a side question about the conversation, even while a turn runs: answered in a panel above the input, without tools, never added to the history. See [Side questions](#side-questions-btw) |
|
|
200
|
+
| `/steer <message>` | Send a correction to the running turn: the model reads it at the next tool boundary and carries on, without the turn ending. See [Mid-turn steering](#mid-turn-steering-steer) |
|
|
199
201
|
| `/notifications [on\|off\|bell\|osc9]` | Turn turn-finished / approval notifications on or off for this session (default from `ui.notifications`) |
|
|
200
202
|
| `/model [<provider/model>] [--active]` | Pick a model: your saved ones (`models:` in config.yaml) first, then "More <provider> models…" for each provider's list (type to filter; Enter on no match uses what you typed). A model that isn't saved yet is added to `~/.dostuff/config.yaml`. A plain `/model` switch lasts only for this session; add `--active` (e.g. `/model --active`, or `/model anthropic/claude-sonnet-5-5 --active`) to make it the default that new sessions start with |
|
|
201
203
|
| `/config [mcp] [project]` | Edit a settings file right in the TUI: pick `config.yaml` or the MCP servers, user (`~/.dostuff`) or project (`./.dostuff`), or name one (`/config mcp project`). `Ctrl+S` checks the file, saves it and applies it without a restart (an invalid file stays open with the error); `Esc` closes, twice if there are unsaved changes. A new file starts with every option commented out. `.env` files aren't offered |
|
|
@@ -230,7 +232,8 @@ In the TUI:
|
|
|
230
232
|
- **Status bar** — `cwd • model • permission mode • context usage %` by default; `help`, `session`, `tokens` and `cost` can be added. Choose and order the items with `ui.status_bar` in `config.yaml`; when the terminal is too narrow (or zoomed in), long items are shortened and the least important dropped (help, session, cwd, tokens, cost, model, context, mode) instead of being cut off
|
|
231
233
|
- **Shells** — while background jobs run, a `⚙ 2 shells` item sits at the end of the status bar whatever `ui.status_bar` says. Click it (or press `↓` in an empty input) to list the session's jobs with when each started and how long it has run, and click it again to close the list; pick one (click or Enter) to see its last 8 lines of output and log path in the same small panel, refresh them, or stop it
|
|
232
234
|
- **Loading** — bold `Working...` with a live elapsed timer and queued-prompt count, or streamed thoughts displayed live
|
|
233
|
-
- **Queued prompts** — prompts
|
|
235
|
+
- **Queued prompts** — prompts that have to wait for the turn sit above the input, one row each, and run in order: skill and custom commands in both modes, plain messages with `ui.mid_turn_messages: queue`. Click the list (or `/queue`) to pick one and edit it (back into the input), run it next or remove it, or clear them all (`/queue clear`). `Esc` cancels the turn and moves the queued prompts back into the input instead of running them
|
|
236
|
+
- **Steering messages** — `/steer <message>` (and every plain message by default; `ui.mid_turn_messages: queue` makes them wait instead) waits for the next tool boundary instead of the end of the turn: the bar leads with `→ N for the agent · read at the next tool boundary`, `/queue` lists them first with Edit / Remove (and *Send now* turns a queued prompt into one), and `Esc` puts a pending one back in the input ahead of the queue. See [Mid-turn steering](#mid-turn-steering-steer)
|
|
234
237
|
- **Terminal title** — the tab / window title shows the run status: `⏳ dostuff · <folder>` while working, `✋` while an approval waits, `✓` when done; the old title comes back on exit. `ui.terminal_title: false` turns it off
|
|
235
238
|
- **Notifications** (off by default) — `ui.notifications: bell` (terminal bell) or `osc9` (desktop notification in iTerm2, WezTerm, Ghostty, kitty …) when a turn finishes or an approval is waiting, if it took longer than `ui.notify_after_seconds` (30) or the terminal is in the background. `/notifications` switches it per session
|
|
236
239
|
|
|
@@ -463,6 +466,90 @@ no `/btw` (only skills and custom commands run there), so `/btw` in a `-p` promp
|
|
|
463
466
|
|
|
464
467
|
---
|
|
465
468
|
|
|
469
|
+
## Mid-turn steering (`/steer`)
|
|
470
|
+
|
|
471
|
+
A message typed while a turn runs normally waits its turn: it joins the queue and runs as its own prompt when the
|
|
472
|
+
current one ends. `/steer <message>` sends a **correction** instead — the model reads it at the next tool boundary and
|
|
473
|
+
carries on with it, without the turn ending and without anything being interrupted:
|
|
474
|
+
|
|
475
|
+
```
|
|
476
|
+
> /steer actually target ./dostuff, not the repo root
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
It lands in the transcript as a user message right after the tool output it was reacting to — where the model read it
|
|
480
|
+
— and the next model call sees it as the newest user message. A final answer that arrives while a correction is still
|
|
481
|
+
waiting does not end the turn: the model reads it and redoes or extends the answer. That check runs before the `Stop`
|
|
482
|
+
hooks, so they see the answer that really ends the turn.
|
|
483
|
+
|
|
484
|
+
What the model reads is framed, not bare: the stored user step is your text wrapped in two fixed lines —
|
|
485
|
+
`The user sent a new message while you were working:` above it, `Address the message above, then continue the task
|
|
486
|
+
you were working on.` below. The loop has no notion of "the task", only the history, so without that instruction a
|
|
487
|
+
standalone question tends to be answered with a final response and the turn ends with the interrupted work left
|
|
488
|
+
mid-flight; Claude Code wraps mid-turn messages the same way. Everything you *see* stays raw — the transcript line,
|
|
489
|
+
Esc-to-restore, and what a leftover re-runs — the frame reaches only the model, plus the stored transcript that
|
|
490
|
+
`/resume` replays.
|
|
491
|
+
|
|
492
|
+
### Two modes
|
|
493
|
+
|
|
494
|
+
`ui.mid_turn_messages` in `config.yaml` decides what a **plain** message does while a turn runs (default `steer`):
|
|
495
|
+
|
|
496
|
+
| Submitted | `queue` | `steer` (default) |
|
|
497
|
+
|---|---|---|
|
|
498
|
+
| Plain message | waits in the queue, runs after the turn | steering: read at the next tool boundary |
|
|
499
|
+
| `/steer <message>` | steering | steering |
|
|
500
|
+
| `/<skill> args`, custom command | waits in the queue | waits in the queue |
|
|
501
|
+
| `/btw`, `/queue`, `/jobs`, … | run now | run now |
|
|
502
|
+
| `/clear`, `/resume`, `/model`, … | refused while a turn runs | refused while a turn runs |
|
|
503
|
+
| `!command` | refused while a turn runs | refused while a turn runs |
|
|
504
|
+
| `#note` (quick memory) | run now | run now |
|
|
505
|
+
|
|
506
|
+
`steer` is the default because it is Claude Code's behaviour: a correction is read now, at the next tool boundary,
|
|
507
|
+
instead of after the turn. `queue` stays one key away for anyone who prefers batching — three instructions typed in a
|
|
508
|
+
row run as three prompts while you are away, and a queued message is never read mid-task when you meant "next".
|
|
509
|
+
`/steer` works in both modes, and with no turn running it is
|
|
510
|
+
an ordinary prompt (it starts a turn), so the habit is never an error. Skills and custom commands stay in the queue in
|
|
511
|
+
both modes: a skill is a turn's prompt, not a correction.
|
|
512
|
+
|
|
513
|
+
### What you see
|
|
514
|
+
|
|
515
|
+
- **On submit** the input clears and the bar above it leads with the steering group, `→ 1 for the agent · read at the next tool boundary`, above the usual `N queued · click or /queue …` rows; the loader counts them separately, `· 1 steering · 2 queued`.
|
|
516
|
+
- **`/queue`** lists the steering messages first, each marked `→`, with *Edit* and *Remove* (once the loop has read
|
|
517
|
+
one, the picker says "That message was already read."), and every queued prompt gained *Send now (at the next tool
|
|
518
|
+
boundary)*, which turns it into a correction.
|
|
519
|
+
- **Attachments are prepared in order**: `@mentions` are expanded and pastes resolved right after you send, in the
|
|
520
|
+
order you sent them, so a message holding a big file never jumps ahead of the one after it. The `Attached …` lines
|
|
521
|
+
show as they finish, as for a prompt.
|
|
522
|
+
- **Hooks and the sandbox still apply**: `UserPromptSubmit` runs for each correction at the boundary, so a hook can
|
|
523
|
+
block it — it is shown like a blocked prompt and never reaches the model — or add context for this turn, written as a
|
|
524
|
+
note right before the correction (the system prompt never changes mid-turn, so the prompt cache holds); a preparation
|
|
525
|
+
failure is reported instead of half-delivered.
|
|
526
|
+
|
|
527
|
+
### Latency, and `Ctrl+B`
|
|
528
|
+
|
|
529
|
+
Delivery waits for the tool call in flight; nothing is interrupted to deliver sooner, so a two-minute `bash_command`
|
|
530
|
+
delays a correction two minutes. While a message waits behind a running command the bar says why —
|
|
531
|
+
`waiting for a running command · Ctrl+B to background it` — and `Ctrl+B` moves the command (or a foreground subagent)
|
|
532
|
+
to the background, which returns the call to the loop at once: the message is read at the next boundary while the
|
|
533
|
+
command keeps running. `Esc` remains the way to stop.
|
|
534
|
+
|
|
535
|
+
### Leftovers
|
|
536
|
+
|
|
537
|
+
A correction can outlive its turn — sent after the final answer's last check, still being prepared, the turn hit the
|
|
538
|
+
iteration cap, the model call failed, or you pressed `Esc`. Nothing is lost:
|
|
539
|
+
|
|
540
|
+
- **Cancelled** (`Esc`) — the raw text goes back into the input **ahead of** the queued prompts: stopping the work
|
|
541
|
+
includes the corrections to it.
|
|
542
|
+
- **Otherwise** — it runs next: `1 message arrived after the turn ended; running it next`, then it is re-prepared from
|
|
543
|
+
what you typed and runs as a normal turn.
|
|
544
|
+
|
|
545
|
+
Either way the text you typed is written to the history exactly once — whether the model read it mid-turn or it ran as
|
|
546
|
+
the next turn.
|
|
547
|
+
|
|
548
|
+
`dostuff -p` has no `/steer` (only skills and custom commands run there), so a `/steer` line in a `-p` prompt is
|
|
549
|
+
ordinary text for the model.
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
466
553
|
## Subagents
|
|
467
554
|
|
|
468
555
|
A subagent is a separate agent with its own context, system prompt and tools. The main agent hands it a task with the
|
|
@@ -805,6 +892,11 @@ permissions:
|
|
|
805
892
|
mode: ask # ask | allowlist | auto | plan
|
|
806
893
|
allow: []
|
|
807
894
|
|
|
895
|
+
ui:
|
|
896
|
+
mid_turn_messages: steer # steer (default): a plain message sent while a turn runs is read by the model at
|
|
897
|
+
# the next tool boundary, inside the running turn | queue: it waits and runs after
|
|
898
|
+
# the turn. /steer sends one either way (see Mid-turn steering)
|
|
899
|
+
|
|
808
900
|
agents: # see Subagents
|
|
809
901
|
max_iterations: 100 # model calls per run; default: loop.max_iterations (older: loop.subagent_max_iterations)
|
|
810
902
|
max_concurrent: 4
|
|
@@ -19,12 +19,15 @@ from dostuff.agent.run_tool import (
|
|
|
19
19
|
)
|
|
20
20
|
from dostuff.helpers.hooks import HookOutcome, run_hooks
|
|
21
21
|
from dostuff.helpers.hooks.dispatch import report_outcome
|
|
22
|
-
from dostuff.helpers.hooks.events import
|
|
22
|
+
from dostuff.helpers.hooks.events import (
|
|
23
|
+
STOP_LIMIT_MESSAGE, STOP_NOTE, session_start, stop_event_for, user_prompt_submit,
|
|
24
|
+
)
|
|
23
25
|
from dostuff.helpers.hooks.run_hook import payload_for
|
|
24
26
|
from dostuff.config import AUTO_COMPACT_THRESHOLD, get_config
|
|
25
27
|
from dostuff.tools.definitions import TOOL_MAP, default_tool_names
|
|
26
28
|
from dostuff.agent.subagents.fork import ForkContext
|
|
27
29
|
from dostuff.helpers.agent.notices import format_notices, get_notice_queue
|
|
30
|
+
from dostuff.helpers.agent.steering import SteerMessage, SteeringQueue, frame_steered
|
|
28
31
|
from dostuff.helpers.agent.side_question import (
|
|
29
32
|
compose_system_instruction, plan_mode_on, publish_snapshot, published_snapshot, usage_dict as build_usage_dict,
|
|
30
33
|
)
|
|
@@ -188,7 +191,7 @@ def _job_events(owner: str, adapter: Any) -> Iterator[None]:
|
|
|
188
191
|
registry.remove_listener(on_job)
|
|
189
192
|
|
|
190
193
|
|
|
191
|
-
async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_instruction: str, mcp_client: MCPClient, working_history: list, turn_type: Literal['interactive_loop', 'subagent_loop'], current_session_history=None, steps_history=None, store=None, adapter=None, compaction_notes: str = "", session_prompt_tokens: int = 0, session_completion_tokens: int = 0, session_total_tokens: int = 0, last_input_tokens: int = 0, stream: bool = True, max_iterations: int = MAX_ITERATIONS, tool_names: list[str] | None = None, permissions: SessionPermissions | None = None, session_hook_context: dict[str, str] | None = None, owner: str | None = None, inbox: list[str] | None = None) -> str:
|
|
194
|
+
async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_instruction: str, mcp_client: MCPClient, working_history: list, turn_type: Literal['interactive_loop', 'subagent_loop'], current_session_history=None, steps_history=None, store=None, adapter=None, compaction_notes: str = "", session_prompt_tokens: int = 0, session_completion_tokens: int = 0, session_total_tokens: int = 0, last_input_tokens: int = 0, stream: bool = True, max_iterations: int = MAX_ITERATIONS, tool_names: list[str] | None = None, permissions: SessionPermissions | None = None, session_hook_context: dict[str, str] | None = None, owner: str | None = None, inbox: list[str] | None = None, steering: SteeringQueue | None = None) -> str:
|
|
192
195
|
"""Run one agent turn. `working_history` is mutated in place (appends and compaction).
|
|
193
196
|
|
|
194
197
|
`session_hook_context` is the caller's per-session SessionStart context (hooks spec REQ-2.4): added to
|
|
@@ -198,9 +201,14 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
|
|
|
198
201
|
|
|
199
202
|
`inbox` is a subagent's `send_message` queue (subagents spec D10): each message becomes a user step before
|
|
200
203
|
the next model call, and a final answer with messages waiting doesn't end the run.
|
|
204
|
+
|
|
205
|
+
`steering` is the TUI's mid-turn messages (steering spec D1): read at the next tool boundary, inside this
|
|
206
|
+
turn. Main session only — a `subagent_loop` never delivers one (CON-008), and `run_agent_loop` doesn't pass it.
|
|
201
207
|
"""
|
|
202
208
|
current_session_id.set(session_id)
|
|
203
209
|
owner = owner or session_id
|
|
210
|
+
# Main session only (CON-008): a subagent's route is send_message, never the steering queue
|
|
211
|
+
steer = steering if turn_type == "interactive_loop" else None
|
|
204
212
|
iteration = 0
|
|
205
213
|
token_limit = get_model_token_limit()
|
|
206
214
|
config = get_config()
|
|
@@ -242,9 +250,52 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
|
|
|
242
250
|
return True
|
|
243
251
|
|
|
244
252
|
async def append_note(text: str) -> None:
|
|
245
|
-
"""A harness-authored user step: a Stop-hook continuation, background notices or a
|
|
253
|
+
"""A harness-authored user step: a Stop-hook continuation, background notices, a send_message or a
|
|
254
|
+
framed steering message."""
|
|
246
255
|
await append_step({"role": "user", "content": text}, steps_history, working_history, current_session_history, session_id, store, turn_type)
|
|
247
256
|
|
|
257
|
+
async def deliver_steer(messages: list[SteerMessage]) -> int:
|
|
258
|
+
"""D6's drain body, shared by the top-of-iteration drain and D7's final-answer path: a failed
|
|
259
|
+
or blocked message is reported and appended nowhere, the rest is written framed and once
|
|
260
|
+
(CON-004) after UserPromptSubmit (CON-007). Hook context, if any, rides ahead of the frame as
|
|
261
|
+
its own note — never a system-instruction fold, which mid-turn would invalidate the provider's
|
|
262
|
+
cached prompt prefix (the system prompt is stable within a turn). Returns how many reached the
|
|
263
|
+
history — D7 re-prompts the model only when that is above zero, never with an unchanged history."""
|
|
264
|
+
delivered = 0
|
|
265
|
+
for steer_msg in messages:
|
|
266
|
+
if steer_msg.failed is not None:
|
|
267
|
+
await loop_emit("steer_failed", {"id": steer_msg.id, "error": steer_msg.failed},
|
|
268
|
+
adapter=adapter)
|
|
269
|
+
continue
|
|
270
|
+
if steer_msg.content is None:
|
|
271
|
+
continue # unreachable: take_ready only returns ready or failed entries
|
|
272
|
+
blocked, context = await user_prompt_submit(
|
|
273
|
+
steer_msg.content, session_id=session_id, turn_id=turn_id, turn_type=turn_type,
|
|
274
|
+
adapter=adapter)
|
|
275
|
+
if blocked is not None:
|
|
276
|
+
await loop_emit("steer_blocked", {"id": steer_msg.id, "reason": blocked},
|
|
277
|
+
adapter=adapter)
|
|
278
|
+
continue
|
|
279
|
+
if context:
|
|
280
|
+
# In-band note, not a system fold: a mid-turn system change would invalidate the
|
|
281
|
+
# provider's whole cached prefix — the system prompt stays byte-stable in a turn.
|
|
282
|
+
await append_note(f"[Context from UserPromptSubmit hooks]\n{context}")
|
|
283
|
+
await append_note(frame_steered(steer_msg.content)) # the steer message's only write (CON-004), framed (D6)
|
|
284
|
+
await loop_emit("steered", {"id": steer_msg.id, "index": len(steps_history) - 1},
|
|
285
|
+
adapter=adapter)
|
|
286
|
+
delivered += 1
|
|
287
|
+
return delivered
|
|
288
|
+
|
|
289
|
+
async def drain_facts() -> None:
|
|
290
|
+
"""Background-job notices and inbox messages, oldest first (D1/D7): both the top of an
|
|
291
|
+
iteration and D7's final-answer path drain them before a correction is delivered, so a
|
|
292
|
+
correction lands after the facts it may be reacting to."""
|
|
293
|
+
notices = get_notice_queue().drain(owner)
|
|
294
|
+
if notices:
|
|
295
|
+
await append_note(format_notices(notices, max_tool_output_chars))
|
|
296
|
+
while inbox: # send_message to this running subagent, oldest first (D10)
|
|
297
|
+
await append_note(inbox.pop(0))
|
|
298
|
+
|
|
248
299
|
def fork_context() -> ForkContext | None:
|
|
249
300
|
"""What a fork started now inherits (subagents spec D11): the history as it is before this response's
|
|
250
301
|
assistant step is appended, and the system prompt parts as this model call got them. Main agent only."""
|
|
@@ -285,11 +336,12 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
|
|
|
285
336
|
return CANCELLED_TURN
|
|
286
337
|
|
|
287
338
|
# Background jobs and agents of this run that ended since the last model call (spec D7)
|
|
288
|
-
|
|
289
|
-
if
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
339
|
+
await drain_facts()
|
|
340
|
+
if steer is not None:
|
|
341
|
+
# The user's mid-turn messages, in submit order (D6): after the notices and the inbox so a
|
|
342
|
+
# correction is read after the facts it may be reacting to, before publish_snapshot so a
|
|
343
|
+
# /btw asked afterwards sees it.
|
|
344
|
+
await deliver_steer(steer.take_ready())
|
|
293
345
|
# What a /btw side question reads while this turn runs (btw spec D3); main agent only
|
|
294
346
|
publish_snapshot(session_id, fork_context())
|
|
295
347
|
|
|
@@ -387,9 +439,36 @@ async def loop(session_id: str, turn_id: str, user_text: str, dynamic_system_ins
|
|
|
387
439
|
"content": content,
|
|
388
440
|
}
|
|
389
441
|
await append_step(model_step, steps_history, working_history, current_session_history, session_id, store, turn_type)
|
|
390
|
-
if inbox:
|
|
442
|
+
if inbox:
|
|
443
|
+
# A send_message arrived during this call: read it instead of ending (D10) — inbox
|
|
444
|
+
# items always append at the drain, so the model always gets something new. Before
|
|
445
|
+
# the Stop hooks, so a Stop hook sees the answer that really ends the turn.
|
|
391
446
|
iter_span.set_status(Status(StatusCode.OK))
|
|
392
447
|
continue
|
|
448
|
+
if steer is not None and steer.has_ready_or_preparing():
|
|
449
|
+
# D7: a steering message arrived during this call — read it instead of ending, but
|
|
450
|
+
# never re-prompt with unchanged history: a failed or blocked message is reported
|
|
451
|
+
# without appending and a still-preparing one appends nothing. Wait for each pending
|
|
452
|
+
# message to settle, deliver what passes, and fall through to the Stop hooks once
|
|
453
|
+
# nothing more will be delivered.
|
|
454
|
+
steer_delivered = 0
|
|
455
|
+
while steer.has_ready_or_preparing() and not steer_delivered:
|
|
456
|
+
if await check_cancelled():
|
|
457
|
+
return CANCELLED_TURN
|
|
458
|
+
steer_taken = steer.take_ready()
|
|
459
|
+
if steer_taken:
|
|
460
|
+
await drain_facts() # D1 order: facts that arrived during the call
|
|
461
|
+
# land before the correction reacting to them (review round 2)
|
|
462
|
+
steer_delivered += await deliver_steer(steer_taken)
|
|
463
|
+
else:
|
|
464
|
+
# preparation in flight: wait for it instead of calling the model again
|
|
465
|
+
# with no new user content (the message arrives at this boundary anyway)
|
|
466
|
+
await asyncio.sleep(0.05)
|
|
467
|
+
if steer_delivered:
|
|
468
|
+
iter_span.set_status(Status(StatusCode.OK))
|
|
469
|
+
continue
|
|
470
|
+
# every pending message failed or was blocked (both already reported above): this
|
|
471
|
+
# answer really ends the turn — fall through to the Stop hooks below.
|
|
393
472
|
|
|
394
473
|
# Stop / SubagentStop: only here, on a final answer, never on cancel, errors or the
|
|
395
474
|
# iteration cap. A block keeps the turn going, at most stop_block_limit times (REQ-2.3)
|