feat: inject rejected-tool feedback as user message (#96)#102
Merged
VforVitorio merged 4 commits intodevfrom Apr 7, 2026
Merged
feat: inject rejected-tool feedback as user message (#96)#102VforVitorio merged 4 commits intodevfrom
VforVitorio merged 4 commits intodevfrom
Conversation
When the user selects "No / Tell lmcode what to do instead" in the interactive approval prompt and types a redirect, the feedback is now stashed in ``Agent._pending_user_feedback`` and injected as a real ``user`` message on the next loop iteration, instead of being returned inline as a tool error string. ``run()`` gains an ``auto_input`` slot that, when set, skips ``session.prompt_async`` and replays the feedback as if the user had just typed it. The interrupted path clears any pending feedback so a stale redirect cannot leak across Ctrl+C. Closes #96.
Adds the `ui/_interactive_prompt.py` file to the module map and key files table, and reformats tables/sections for consistency.
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.
Summary
Finishes the last missing piece of #96 (extended interactive prompt).
The arrow-key approval menu in ask mode already offered three options
(Yes, No / Tell lmcode what to do instead, Always) thanks to
PR #95, but when the user typed a redirect instruction after choosing
No, the text was returned inline as a tool error string. That made
the model treat the user's words as tool output and the context felt
off.
This PR routes the feedback through
Agent._pending_user_feedbackandreplays it as a real
userturn on the next iteration of the chat loop.Changes
Agent.__init__: new_pending_user_feedback: str | Noneslot._wrap_tool: when the user types redirect text, stash it and returna generic
Tool execution cancelled by usererror so the modelstops retrying and waits.
run(): newauto_inputvariable. When set, the next loop iterationskips
session.prompt_asyncand replays the feedback as if the userhad typed it at the prompt (complete with a dim
› <text>row so theinjection is visible).
_pending_user_feedbackso Ctrl+C cannotleak a stale redirect into the next turn.
CLAUDE.md: documentsui/_interactive_prompt.pyin the module mapand key files table.
Resulting history flow
```
user: write to /x/y.py
assistant: [tool_call write_file]
tool: error: Tool execution cancelled by user. Do not retry...
assistant: ok, cancelled. Waiting for your new instructions.
user: write it to /x/z.py instead ← injected as a real user turn
assistant: [tool_call write_file with new path]
```
Test plan
Closes #96.