Skip to content

Conversation

@bryan-ash
Copy link
Contributor

@bryan-ash bryan-ash commented Jul 27, 2025

What this does

This PR adds a new callback hook to Chat that sends information when a tool call is initiated by the model. This is useful when building a coding agent to show the user progress of interactions inline with streaming responses.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Performance improvement

Scope check

  • I read the Contributing Guide
  • This aligns with RubyLLM's focus on LLM communication
  • This isn't application-specific logic that belongs in user code
  • This benefits most users, not just my specific use case
    • this is beneficial to all users who want to show tool call indications to the user

Quality check

  • I ran overcommit --install and all hooks pass
  • I tested my changes thoroughly
  • I updated documentation if needed
  • I didn't modify auto-generated files manually (models.json, aliases.json)

API changes

  • Breaking change
  • New public methods/classes
  • Changed method signatures
  • No API changes

Related issues

N/A

This is useful when you want to show to the user tool calls as they
are made, particularly when handling streamed output.
@bryan-ash bryan-ash force-pushed the add-on_tool_call-callback branch from 2e30ed7 to bcce1d0 Compare July 27, 2025 18:45
@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.64%. Comparing base (1f8865a) to head (65e0c1c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #299      +/-   ##
==========================================
+ Coverage   86.62%   86.64%   +0.01%     
==========================================
  Files          79       79              
  Lines        3125     3129       +4     
  Branches      612      613       +1     
==========================================
+ Hits         2707     2711       +4     
  Misses        418      418              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@crmne crmne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@crmne crmne merged commit a9a1446 into crmne:main Jul 30, 2025
14 checks passed
crmne pushed a commit that referenced this pull request Aug 1, 2025
## What this does

An `on_tool_call` callback was added in `1.4.0` via
#299, but it doens't work with a
model using the rails integration via `acts_as_chat`.

This PR wires up the missing method so it works with the integration.

## Type of change

- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation
- [ ] Performance improvement

## Scope check

- [x] I read the [Contributing
Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md)
- [x] This aligns with RubyLLM's focus on **LLM communication**
- [x] This isn't application-specific logic that belongs in user code
- [x] This benefits most users, not just my specific use case

## Quality check

- [ ] ~I ran `overcommit --install` and all hooks pass~
- When I tried to commit the hooks generated a bunch of changes to
`models.json` and `aliases.json` and broke a bunch of the specs, so I
removed the hooks and ran specs and rubocop manually
- [x] I tested my changes thoroughly
- [x] I updated documentation if needed
  - No need
- [x] I didn't modify auto-generated files manually (`models.json`,
`aliases.json`)

## API changes

- [ ] Breaking change
- [ ] New public methods/classes
- [ ] Changed method signatures
- [x] No API changes

## Related issues

<!-- Link issues: "Fixes #123" or "Related to #123" -->
tpaulshippy pushed a commit to tpaulshippy/ruby_llm that referenced this pull request Aug 3, 2025
## What this does

This PR adds a new callback hook to `Chat` that sends information when a
tool call is initiated by the model. This is useful when building a
coding agent to show the user progress of interactions inline with
streaming responses.

## Type of change

- [ ] Bug fix
- [x] New feature
- [ ] Breaking change
- [ ] Documentation
- [ ] Performance improvement

## Scope check

- [x] I read the [Contributing
Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md)
- [x] This aligns with RubyLLM's focus on **LLM communication**
- [x] This isn't application-specific logic that belongs in user code
- [x] This benefits most users, not just my specific use case
- this is beneficial to all users who want to show tool call indications
to the user

## Quality check

- [x] I ran `overcommit --install` and all hooks pass
- [x] I tested my changes thoroughly
- [x] I updated documentation if needed
- [x] I didn't modify auto-generated files manually (`models.json`,
`aliases.json`)

## API changes

- [ ] Breaking change
- [x] New public methods/classes
- [ ] Changed method signatures
- [ ] No API changes

## Related issues

N/A

---------

Co-authored-by: Carmine Paolino <[email protected]>
tpaulshippy pushed a commit to tpaulshippy/ruby_llm that referenced this pull request Aug 3, 2025
…#318)

## What this does

An `on_tool_call` callback was added in `1.4.0` via
crmne#299, but it doens't work with a
model using the rails integration via `acts_as_chat`.

This PR wires up the missing method so it works with the integration.

## Type of change

- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation
- [ ] Performance improvement

## Scope check

- [x] I read the [Contributing
Guide](https://github.com/crmne/ruby_llm/blob/main/CONTRIBUTING.md)
- [x] This aligns with RubyLLM's focus on **LLM communication**
- [x] This isn't application-specific logic that belongs in user code
- [x] This benefits most users, not just my specific use case

## Quality check

- [ ] ~I ran `overcommit --install` and all hooks pass~
- When I tried to commit the hooks generated a bunch of changes to
`models.json` and `aliases.json` and broke a bunch of the specs, so I
removed the hooks and ran specs and rubocop manually
- [x] I tested my changes thoroughly
- [x] I updated documentation if needed
  - No need
- [x] I didn't modify auto-generated files manually (`models.json`,
`aliases.json`)

## API changes

- [ ] Breaking change
- [ ] New public methods/classes
- [ ] Changed method signatures
- [x] No API changes

## Related issues

<!-- Link issues: "Fixes crmne#123" or "Related to crmne#123" -->
@bryan-ash bryan-ash deleted the add-on_tool_call-callback branch September 6, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants