Add experimental agent mode for binding.agent#1188
Draft
st0012 wants to merge 1 commit into
Draft
Conversation
fcfcea9 to
98c28c6
Compare
ae4de56 to
ecf744e
Compare
ecf744e to
6a02408
Compare
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
Agents usually interact with programs through non-interactive shell commands, so a process that stops at
binding.irbcan leave them stranded at a TTY REPL they cannot reliably drive.That makes the most useful debugging workflow hard to automate: discover the breakpoint, inspect live locals and receiver state, try IRB commands, make a small state change if needed, and then let the original Ruby program continue.
The breakpoint also needs to teach the agent how to reconnect without assuming a dedicated client library or prior IRB-specific setup.
Solution
binding.agent, a two-phase breakpoint for non-interactive agents and scripts.IRB_SOCK_PATHis absent.lsandshow_source, and mutate live state before resuming the host program withexit.require "irb"; binding.agentsetup.Agent Flow
sequenceDiagram participant Agent participant Shell participant App as "Ruby app" participant Remote as "IRB::RemoteServer" Agent->>Shell: ruby app.rb Shell->>App: run without IRB_SOCK_PATH App-->>Agent: print socket workflow and exit Agent->>Shell: IRB_SOCK_PATH=/tmp/irb.sock ruby app.rb & Shell->>App: restart app in background App->>Remote: binding.agent opens socket server loop one command per connection Agent->>Remote: connect, send command, close_write Remote->>Remote: evaluate in persistent binding Remote-->>Agent: return IRB output and close end Agent->>Remote: exit Remote->>App: close server and resumeEnd-to-End Notes
exit.binding.agentand still resume the host script.IRB_SOCK_PATH, then use short foreground socket commands for the interactive loop.