Repository navigation
interrupt: return the agent from LLM.interrupt - #293
Merged
Merged
Conversation
Member
|
Thanks for the patch! |
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.
Fixes #292
LLM.interruptnow returns the agent it found and interrupted instead oftrue, and still returnsfalsewhen nothing was registered. On a hit it returns from insideattempts.times; on a miss it returnsfalseafter the loop, so it can't fall through to the Integer thattimesreturns.lib/llm.rb: return the agent, and@return [LLM::Agent, false].spec/llm/interrupt_spec.rb:be(true)is nowbe(agent), plus an example that the returned agent hadinterrupt!called on it. Thefalsecases are unchanged.docs/deepdive/advanced/cancellation.md: a hit answers with the agent it interrupted.README.md: the interrupt section said the method "returns true when it sent an interrupt", so it now says it returns the agent. This one wasn't in the issue's steps.CHANGELOG.md: a Migration row and an Agent entry under "What's next", since the issue asks for one. It says it's a soft break:== truestops matching, and a caller that stores or serializes the result (a JSON response, say) now gets the agent. I see contributor PRs here usually leave the changelog to you, and aBreakingheading implies the next major, so feel free to drop or reword it.I kept the local named
record, as in the issue's sketch, to keep the diff small. Happy to rename it tofoundif you prefer.Verified locally on Ruby 4.0.6 (Docker), with the Linux CI job's env (
JSON_PARSER=JSON,DASHSCOPE_API_HOSTset):bundle exec rspec spec/llm/interrupt_spec.rb: the two changed examples fail on main (they gettrue) and pass with the change; 10 examples, 0 failures.bundle exec rake spec: 1962 examples, 0 failures, 37 pending (the PostgreSQL ORM specs, sinceLLMRB_POSTGRESQL_URLwasn't set). On main: 1961 examples, 0 failures, 37 pending.bundle exec rubocop lib/llm.rb spec/llm/interrupt_spec.rb: no new offenses. The twoStyle/ItBlockParameteroffenses inlib/llm.rbare on main too.