Skip to content

Experimental tools: add runTools page-side agent loop helper - #34

Merged
SamSamskies merged 2 commits into
mainfrom
feat/experimental-run-tools
Aug 13, 2026
Merged

Experimental tools: add runTools page-side agent loop helper#34
SamSamskies merged 2 commits into
mainfrom
feat/experimental-run-tools

Conversation

@SamSamskies

Copy link
Copy Markdown
Owner

Summary

  • Adds window.inference.experimental.runTools to orchestrate the multi-turn function-tool loop (page-owned execute handlers; Bridge still does not run tools).
  • Extracts the shared loop into src/run-tools.js with unit tests (happy path, missing executor, maxRounds, abort, serialization).
  • Keeps stable window.inference.request unchanged.

Resolves #26

Test plan

  • Run npm test (or project test script) and confirm test/run-tools.test.js passes
  • In a page with the extension loaded, call window.inference.experimental.runTools with a simple execute map and verify tool rounds + final text
  • Confirm missing execute handler and maxRounds exhaustion throw as expected
  • Confirm stable window.inference.request behavior is unchanged

Made with Cursor

- Introduced the `runTools` function to facilitate a structured loop for executing tools within the application, allowing for multiple rounds of tool calls and responses.
- Implemented validation for input options, ensuring that required parameters such as messages and maxRounds are correctly provided.
- Enhanced error handling for aborted requests and invalid tool calls, improving robustness during tool interactions.
- Updated the global `inference` object to include the new `runTools` function, making it accessible for use in the application.

These changes significantly improve the management of tool interactions, enabling more complex and flexible use cases in multi-turn conversations.
- Updated the `serializeToolResult` function in `run-tools.js` and `inject.js` to ensure that undefined values are serialized as the string "null" instead of returning undefined. This change improves consistency in the output of serialized tool results.
- Added a test case in `run-tools.test.js` to verify the correct serialization of undefined values, ensuring robust functionality and preventing potential issues in tool interactions.

These modifications enhance the reliability of tool result serialization, improving the overall handling of tool outputs in the application.
@SamSamskies
SamSamskies merged commit 1945553 into main Aug 13, 2026
1 check passed
@SamSamskies
SamSamskies deleted the feat/experimental-run-tools branch August 13, 2026 22:46
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.

Experimental tools: runTools helper for page-side agent loop

1 participant