文件历史

43 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 73bb0221b2 Guaranteed tool call IDs (#1481)
* Guarantee every tool call has a unique tool_call_id

add_tool_call() now synthesizes a unique tc_-prefixed id (monotonic
ULID) whenever the provider did not supply one. Previously consumers
correlating tool calls with results - or keying external state on a
specific invocation - had to invent fallback matching schemes for
id-less providers, and test models like llm-echo exercised different
code paths than production providers.

Provider-supplied ids are preserved untouched, and responses
rehydrated from the logs database keep their stored ids (synthesis
only happens at add_tool_call time). Existing tests that asserted
tool_call_id None now normalize or mask the synthesized ids.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 14:04:26 -07:00
Simon Willison c8889e0a76 Ran black 2026-03-17 11:25:12 -07:00
Simon Willison c6e158071a Ran black 2025-08-11 21:47:11 -07:00
Simon Willison e6ac18fbcb Fix for confusing error, closes #1238 2025-08-11 16:52:16 -07:00
Simon Willison 08094082f2 Toolbox.add_tool(), prepare() and prepare_async() methods
Closes #1111
2025-08-11 13:19:31 -07:00
Simon Willison 30e0c4abe8 ToolResult.exception for tool errors, now logged to DB
Closes #1104
2025-06-01 17:01:40 -07:00
Simon Willison b5d1c5ee90 Tools can now return attachments
Closes #1014

- llm.ToolOutput(output='...', attachments=[...]) for tools to return attachments
- New table: `tool_results_attachments`
- Table is populated when tools return attachments
- llm --tools-debug shows attachments returned by tools
- llm logs shows attachments returned by tools
2025-06-01 10:08:36 -07:00
Simon Willison 330a568683 Raise error if a non-Toolbox subclass is passed to register(), closes #1114 2025-05-30 21:37:41 -07:00
Simon Willison dbb02d65b9 Fix for llm_time plugin test 2025-05-27 10:26:08 -07:00
Simon Willison 2bc6d7679c New default tool, llm_time, closes #1103 2025-05-26 23:00:18 -07:00
Simon Willison d1c5c688e2 Error on llm -c with a Toolbox, closes #1101
Refs #1092
2025-05-26 21:51:16 -07:00
Simon Willison e4ecb86421 Log tool_instances to database (#1098)
* Log tool_instances to database, closes #1089
* Tested for both sync and async models
2025-05-26 21:01:55 -07:00
Simon Willison c9e8593095 Assert specific order again thanks to monotonic ULIDs, refs #1099 2025-05-26 20:03:22 -07:00
Simon Willison 57459c0a6e Fix the tests I broke in #1096 2025-05-26 19:02:14 -07:00
Simon Willison 00f44a848a Test that async def methods work on Toolbox 2025-05-26 10:08:31 -07:00
Simon Willison bb336d33a0 Toolbox class for class-based tool collections (#1086)
* Toolbox class for class-based tool collections

Refs #1059, #1058, #1057
2025-05-25 22:42:52 -07:00
Simon Willison abc4f473f4 --td now pretty-prints JSON if possible, closes #1083 2025-05-25 12:59:48 -07:00
Simon Willison 713ee9b032 Ignore order in test, refs #1073, #1079 2025-05-24 13:18:09 -07:00
Simon Willison 4281fd5101 Fixed test for #1073 2025-05-23 23:26:33 -07:00
Simon Willison 8a1fc5a90e llm logs --tool/-T option, closes #1013 2025-05-23 21:46:10 -07:00
Simon Willison 36477cf9e5 llm chat -c and llm -c carry forward tools, closes #1020 2025-05-23 21:10:51 -07:00
Simon Willison 3cbc37a470 Log tool plugin to database
Refs https://github.com/simonw/llm/issues/1020#issuecomment-2905968166
2025-05-23 15:59:43 -07:00
Simon Willison d2886d4692 Record which plugin a tool came from, including in DB - refs #1020 2025-05-23 15:44:12 -07:00
Simon Willison e90705ebf1 Respect name= for register_tools, closes #1032 2025-05-21 21:53:22 -07:00
Simon Willison 0ee1ba3a65 Ditch SimpleEcho entirely for Echo, closes #1061 2025-05-20 22:02:04 -07:00
Simon Willison bd2180df7d llm chat --tool and --functions (#1062)
* Tool support for llm chat, closes #1004
2025-05-20 21:30:27 -07:00
Simon Willison e48a5b9f11 Rename "echo" to "simple-echo", refs #1061 2025-05-20 20:55:54 -07:00
Simon Willison 4be2bbdc0e Ensure test does not fail due to random sort order of plugins 2025-05-20 20:53:35 -07:00
Simon Willison f879b816e4 llm plugins --hook X option, closes #1047 2025-05-18 14:50:34 -04:00
Simon Willison a880c123bd --tools is now --functions, can be path, can be multiple
Closes #1016
2025-05-13 17:19:30 -07:00
Simon Willison 7efe51fcb4 Rename --python-tools to --tools, closes #1008 2025-05-13 17:19:30 -07:00
Simon Willison 4abd6e0faf Made a start on tools.md docs, refs #997
Also documented register_tools() plugin hook, refs #991
2025-05-13 17:19:30 -07:00
Simon Willison 0f114be5f0 --python-tools option on prompt and tools, closes #995 2025-05-13 17:19:30 -07:00
Simon Willison 8d5fc87028 llm tools and llm tools --json, closes #994 2025-05-13 17:19:30 -07:00
Simon Willison 290c0f13f3 register_tools() hook, get_tools() utility
Refs #991
2025-05-13 17:19:30 -07:00
Simon Willison e02863c1ca Fragment plugins can now optionally return attachments (#974)
Closes #972
2025-05-04 14:50:27 -07:00
Simon Willison c9f64096c9 llm fragments loaders, closes #941 2025-04-20 07:56:27 -07:00
Simon Willison a571a4e948 register_fragment_loaders() hook (#886)
* Docs and shape of register_fragment_loaders hook, refs #863
* Update docs for fragment loaders returning a list of FragmentString
* Support multiple fragments with same content, closes #888
* Call the pm.hook.register_fragment_loaders hook
* Test for register_fragment_loaders hook
* Rename FragmentString to Fragment

Closes #863
2025-04-06 17:03:34 -07:00
Simon Willison 6c9a8efb50 register_template_loaders plugin hook, closes #809
* Moved templates CLI commands next to each other
* llm templates loaders command
* Template loader tests
* Documentation for template loaders
2025-03-21 16:46:44 -07:00
Simon Willison ae87f978bd Moved iter_prompt from Response to Model, moved a lot of other stuff
- Moved a whole bunch of things from llm/cli.py into llm/__init__.py
- Switched plugin listings to use importlib.metadata to avoid deprecation warning
- iter_prompt() is now a method on Model, not on Response
2023-07-10 07:45:11 -07:00
Simon Willison 4a9f7f4908 Lint using Ruff, refs #78 2023-07-02 12:41:40 -07:00
Simon Willison 14ce371007 Fix plugins tests to account for default plugins 2023-07-01 11:06:28 -07:00
Simon Willison a396950f79 Initial plugin framework and register_commands(cli) hook, refs #49 2023-06-17 17:42:13 +01:00