feat(zarvis): steer the agent mid-turn between tool steps#193
Merged
Conversation
Previously a prompt typed while a turn was running was enqueued and only picked up after the *entire* turn finished — the user couldn't redirect the agent between tool calls. Now, at each step boundary (after a step's tool results are appended, before the next model request), any input the user enqueued during the step is folded into the conversation as a user message, so the model incorporates the new guidance on its very next step. This is additive steering, not an interrupt: in-flight model/tool work isn't aborted (Stop / Interrupt remain the way to abort). Input typed during the silent provider stream / tool execution is back-filled into the chat history (echo + Message event) just like the outer loop's queued-input path. Adds `drain_steering` (newline-joins the queued entries, empties the queue) with unit tests, including the coalesced-multi-submit case.
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.
Problem
In a zarvis session, a prompt typed while a turn is running is enqueued but only consumed after the entire turn finishes — so you can't redirect the agent between tool calls while it's working on a multi-step task.
Change
At each step boundary of a turn (after that step's tool results are appended to the conversation, before the next model request), drain anything the user typed during the step and fold it in as a
Usermessage. The model then incorporates the steering on its very next step — no need to wait for the whole turn to end.This is additive steering, not an interrupt — in-flight model/tool work is never aborted. Stop / Interrupt (Ctrl-C) remain the way to abort. Input typed during the silent provider stream / tool execution is back-filled into the chat history (PTY echo +
Messageevent) exactly like the outer loop's queued-input path, so it shows up where you'd expect.Provider-safe: injecting a user message after tool results is the standard interjection pattern; the Anthropic adapter already emits consecutive user-role messages for multi-tool turns, and OpenAI/Ollama accept user-after-tool.
Notes
Tests
drain_steeringhelper + unit tests: empty → none; multi-entry → newline-joined and queue emptied; and the coalesced multi-submit case (enqueue_linecombines consecutive submits, whitespace ignored).agentd-adapter-zarvissuite (126) green;--lockedworkspace build clean.🤖 Generated with Claude Code