提交

1100 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 0392226e66 Release notes for 0.31.1
Update Stable Docs / update_stable_docs (push) Has been cancelled
Test / test (macos-latest, 3.10, ) (push) Has been cancelled
Test / test (macos-latest, 3.11, ) (push) Has been cancelled
Test / test (macos-latest, 3.12, ) (push) Has been cancelled
Test / test (macos-latest, 3.13, ) (push) Has been cancelled
Test / test (macos-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, 4.0rc4) (push) Has been cancelled
Test / test (windows-latest, 3.10, ) (push) Has been cancelled
Test / test (windows-latest, 3.11, ) (push) Has been cancelled
Test / test (windows-latest, 3.12, ) (push) Has been cancelled
Test / test (windows-latest, 3.13, ) (push) Has been cancelled
Test / test (windows-latest, 3.14, ) (push) Has been cancelled
Refs #1521
2026-07-09 09:07:51 -07:00
Simon Willison ef6fc13631 Handle tool calls with empty arguments better, closes #1521 2026-07-09 09:03:13 -07:00
Simon Willison 16870b77d2 Test LLM against sqlite-utils>=4.0rc4
Refs https://github.com/simonw/sqlite-utils/issues/769#issuecomment-4900497417
2026-07-06 22:42:01 -07:00
Simon Willison dfe1278757 Test against sqlite-utils 4.0rc3
Refs https://github.com/simonw/sqlite-utils/issues/769#issuecomment-4889420844
2026-07-05 22:47:41 -07:00
Simon Willison ef2eadf768 Only run cog check on sqlite-utils 4.0rc2
Refs https://github.com/simonw/sqlite-utils/issues/758#issuecomment-4886940409
2026-07-05 10:32:16 -07:00
Simon Willison ba46960fe9 Test against sqlite-utils 4.0rc2
Refs https://github.com/simonw/sqlite-utils/issues/758#issuecomment-4886879441
2026-07-05 10:19:23 -07:00
Simon Willison 67adad2c10 Use db.execute() not db.query()
This gets us working with sqlite-utils 4.0rc2

Refs https://github.com/simonw/sqlite-utils/issues/758
2026-07-05 10:17:34 -07:00
Simon Willison 2462813aa0 Show just first 7 characters of tool hashes
Refs https://github.com/simonw/llm/issues/1515#issuecomment-4886840756
2026-07-05 10:05:45 -07:00
Simon Willison 556c1eaa14 Dedupe tool descriptions in logs, better argument display, closes #1515 2026-07-05 10:00:06 -07:00
Simon Willison 94769b8b07 Fix for test that fails with sqlite-utils 4.0rc1
Refs #https://github.com/simonw/sqlite-utils/issues/758#issuecomment-4763695884
2026-06-21 17:19:59 -07:00
Simon Willison a66a38f16e Apply pytest fix again, refs #1024
We had new code that post-dated the PR that fixed this.
2026-06-21 17:12:32 -07:00
Simon Willison 5126595472 Revert "Only package llm"
This reverts commit 3c9608d0ed.

I had made this change already.
2026-06-21 17:09:44 -07:00
Simon Willison 3c9608d0ed Only package llm
This avoids problems if I have untracked directories in here.
2026-06-21 17:09:11 -07:00
Mrmaxmeier 6f2dba429a Update click to >8.2.0
The was previously blocked by removed support of Python 3.9, but we
have since dropped support as well: dd227cdcd1

Closes #1024
2026-06-21 17:08:40 -07:00
Simon Willison 4da36ff523 Try sqlite-utils 4.0rc1 in CI
Also output current sqlite-utils version in pytest headers

Refs https://github.com/simonw/sqlite-utils/issues/758
2026-06-21 16:49:22 -07:00
Labib Bin Salam af977da5ca Fix typos in documentation (#1486)
- tools.md: drop the stray article in "every tool is a defined as" and the doubled word in "Toolbox classes can be be configured".
- contributing.md: fix the doubled "an an" in the example prompt (both the streaming and --no-stream snippets).
2026-06-15 10:01:40 -07:00
Eldar Shlomi b7e213282d docs: fix wrong hook name and typo in register_fragment_loaders section (#1489)
The description of the `register_fragment_loaders` hook incorrectly
referred to `register_template_loaders` as the hook to use. These are
two distinct hooks; fragment loader plugins must use
`register_fragment_loaders`.

Also fixed a typo: "de-duplicatino" → "de-duplication".

AI-assisted contribution.
2026-06-15 10:00:48 -07:00
Niall Smart 0d593ea2a4 Include system prompt in pre-baked chain messages
Closes #1478
2026-06-09 15:47:25 -07:00
Simon Willison d492388220 Upgrade GitHub Actions 2026-06-09 15:32:08 -07:00
Simon Willison 5fe711964e Update docs/fragments.md 2026-06-09 15:31:54 -07:00
Simon Willison 1e72f0a0e4 Spelling for Datasette Agent
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
0.32a3
2026-06-09 15:25:37 -07:00
Simon Willison 2ae7089508 Release 0.32a3
Refs #1480, #1481, #1482, #1482, #1482, #1483
2026-06-09 15:25:01 -07:00
Simon Willison 92a9ca7cbf Async tool calls to missing tools now produce error results (#1483)
The async execute_tool_calls() silently dropped calls to tools that
were not in tools= (or had no implementation): output and exception
were assigned but no ToolResult was ever appended, so the next
provider call carried an assistant tool_call with no matching result
- which OpenAI and Anthropic reject. The sync executor already
returned an 'Error: tool ... does not exist' result.

The async path now mirrors the sync one: before_call fires (and can
CancelToolCall) even though the tool is unavailable, and an error
ToolResult is appended in call order. Also removes the now-unreachable
tool-is-None branch from the inline sync-implementation path.

This matters more since chain resume landed: a pending call whose
tool is no longer registered would otherwise never resolve.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 15:17:37 -07:00
Simon Willison 3ac0a23381 PauseChain primitive + chain resume from pending tool calls (#1482)
* PauseChain primitive + chain resume from pending tool calls

Two features that together give chains a first-class suspend/resume
story for human-in-the-loop tools:

llm.PauseChain: raise inside a tool implementation to stop the chain
cleanly. Unlike other exceptions it is not converted into an error
ToolResult - it propagates to the caller with .tool_call (the paused
call) and .tool_results (completed sibling results) attached, and no
provider call is made with a placeholder result. Failure semantics
for concurrent tool execution are now defined: async sibling tasks
always run to completion before a pause or hook exception propagates
(gather with return_exceptions, raised after collection), so nothing
is orphaned mid-flight; sync execution stops at the paused call,
leaving later calls unstarted so they can safely run on resume.

Chain resume: chain(messages=history, tools=...) now detects a
history ending in an assistant message with unresolved tool calls -
e.g. one persisted when a previous run paused or crashed - executes
those calls through the normal before_call/after_call machinery
(skipping any that already have results), then sends the results to
the model as a standard tool-result turn. A resumed call may pause
again, enabling multi-question flows. Histories where a user or
assistant message follows the calls are left alone. Also adds
execute_tool_calls(tool_calls_list=) for executing an explicit list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 15:07:27 -07:00
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 b865ede0f1 Tool implementations can receive the ToolCall via llm_tool_call param (#1480)
* Tool implementations can receive the ToolCall via llm_tool_call parameter

Tool functions (sync or async, including Toolbox methods) that declare
a parameter named llm_tool_call are now passed the llm.ToolCall object
for the current invocation. The parameter is reserved: it is excluded
from the input schema exposed to the model and is only injected when
declared explicitly - a **kwargs catch-all does not receive it.

This lets tool implementations key external state against the unique
tool_call_id, e.g. for human-in-the-loop approval flows that need to
resume a specific tool call after the answer arrives.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Ran Black

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 13:51:39 -07:00
Simon Willison be27b91aa8 Fixed broken link 2026-05-16 18:38:18 -07:00
Simon Willison 8aba606447 Release 0.32a2
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Refs #1432, #1433, #1435, #1441, #1442
0.32a2
2026-05-12 10:43:00 -07:00
Simon Willison 5a2e0a4c54 --hide-reasoning and hide_reasoning=True parameters (#1442)
* Rename --no-reasoning flag to --hide-reasoning
* hide_reasoning= Prompt parameter, plus docs
* OpenAI plugin now obeys prompt.hide_reasoning
2026-05-12 09:24:51 -07:00
Simon Willison a05e14c5c0 Fixed outdated test, refs #1435 2026-05-12 08:44:07 -07:00
Simon Willison 74437d3dfe "llm -m model --options" to see model options 2026-05-12 08:38:47 -07:00
Simon Willison 40549b21a2 OpenAI Responses API model classes (PR #1435) 2026-05-12 08:32:30 -07:00
Simon Willison 6e12258c0b Send prior assistant text as plain string in OpenAI Responses input
When building the `input` list for the OpenAI Responses API from prior
conversation turns, an assistant text-only turn was being serialized as:

    {"role": "assistant",
     "content": [{"type": "output_text", "text": "..."}]}

The openai-python SDK's EasyInputMessage shape uses a plain string for
this case, matching what a direct OpenAI Responses call would send. Use
the same shape so our history matches the SDK exactly, and add tests
covering both _build_responses_input and a two-turn response.reply()
flow.
2026-05-12 08:19:17 -07:00
Simon Willison 3e9e3a30ea Request reasoning summary auto for OpenAI models 2026-05-11 23:06:52 -07:00
Simon Willison 3b5eaedb87 Run latest black 2026-05-11 22:40:03 -07:00
github-actions[bot] 7e6643d87d Ran cog 2026-05-12 05:34:11 +00:00
Simon Willison 98e651075f Register more OpenAI models using Responses API 2026-05-11 22:33:28 -07:00
Simon Willison 2297a2aab0 Fix for ruff 2026-05-11 21:37:47 -07:00
Simon Willison 2838388c31 Ran Black 2026-05-11 21:18:40 -07:00
Simon Willison 070ba8e85e Merge remote-tracking branch 'origin/main' into claude/research-openai-tool-calls-595q7 2026-05-11 20:47:36 -07:00
Simon Willison 6952ff1c95 Ensure add_tool_call() is emitted as a Part, if necessary
Response keeps two parallel stores: _stream_events (read by to_dict /
response.messages) and _tool_calls (read by execute_tool_calls). Only
the messages were correctly serialized, leaving _tool_calls unrecorded.

Part assembly now also walks _tool_calls and appends a ToolCallPart
for any tool_call_id not already represented by a StreamEvent-derived
Part.

Closes #1433
2026-05-11 20:45:37 -07:00
github-actions[bot] c564fbe24b Ran cog 2026-05-06 04:48:51 +00:00
Claude 1a56805ceb Verify tool calls during reasoning work end-to-end
The previous commit wired up encrypted_content round-trip but only
tested that the data flows through correctly on a single tool round-
trip. This adds a multi-turn cassette test that proves the full
interleaved-reasoning capability:

- Each turn produces fresh reasoning_tokens (not just the first)
- Every prior reasoning block is round-tripped on every subsequent
  turn (the Nth turn echoes >= N-1 reasoning items)
- ReasoningParts persisted on the assistant messages carry the same
  encrypted_content + id that gets sent back on the wire

The puzzle is shaped so the model can't parallelize tool calls -
each db_lookup result tells it the next key to use, forcing the
model to think between calls. The recorded 4-turn chain shows
reasoning_tokens of 45/98/196/17 across turns with reasoning items
accumulating in every outgoing input.

This is the GPT-5-class capability that Chat Completions can't
deliver because it discards reasoning between turns.
2026-05-06 04:14:04 +00:00
Claude c7464eeb97 Round-trip encrypted reasoning across tool calls
When the Responses API returns a reasoning item alongside function
calls, capture its opaque id + encrypted_content as provider_metadata
on the resulting ReasoningPart. _build_responses_input already echoed
that metadata back as a reasoning input item on the next turn - now
the output side actually populates it.

This preserves the model's hidden chain of thought across the tool
round-trip. Without it, GPT-5-class models silently lose ~3% on
SWE-bench (per OpenAI) when used with tools.

Adds a dedicated VCR test that asserts the encrypted_content captured
on the first turn appears verbatim in the second turn's outgoing
request body.
2026-05-06 03:15:21 +00:00
Claude 3c747c8b9f Route gpt-5.5 through the /v1/responses endpoint
Adds Responses and AsyncResponses classes that drive the OpenAI
/v1/responses endpoint. The existing Chat / AsyncChat classes are
unchanged because other plugins import them.

gpt-5.5 (and gpt-5.5-2026-04-23) is now registered against Responses
by default. Pass `-o chat_completions 1` to fall back to the older
/v1/chat/completions code path.

This is feature parity with the Chat path (text, tools, streaming,
schema, reasoning_effort, verbosity, attachments, system prompts).
Interleaved reasoning across tool round-trips is not exercised yet -
encrypted reasoning items are accepted on the input side, but the
plugin doesn't yet stash them on outgoing ReasoningParts.
2026-05-06 01:57:09 +00:00
Simon Willison 3d0321fbb4 Add options= dict parameter to .prompt() and .reply() (#1432)
Accepts model options as an explicit dict alongside the existing
**kwargs form. The kwargs form continues to work unchanged for
backwards compatibility but is no longer documented. Mixing the two
forms with overlapping keys raises TypeError.

Applies to Model.prompt, Conversation.prompt, Response.reply and
their async equivalents. .chain() already used this pattern.

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-04 20:57:01 -07:00
Simon Willison 9a5c24e20c Release 0.32a1
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Refs #1426

Refs https://github.com/simonw/llm-anthropic/issues/68
0.32a1
2026-04-29 16:52:09 -07:00
Simon Willison 4d92df12a6 Rebuild prompt.messages chain when loading logged conversations
Each row stores only its current-turn inputs, so a loaded tool-result
response began with an orphan tool_result. `llm -c` then sent a request
with an unexpected tool_use_id. Stitch each response's messages onto the
previous response's chain plus its assistant output during load.

Closes #1426

Refs https://github.com/simonw/llm-anthropic/issues/68

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 16:39:03 -07:00
Simon Willison cce6ed956a Ran cog 2026-04-29 12:02:36 -07:00
Simon Willison 35c35dac43 Release 0.32a0
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Closes #1314, #506, #1278, #894, #813, #468, #346, #716, #770, #867, #938, #1033, #937

Refs #1067, #1080
0.32a0
2026-04-29 11:55:20 -07:00