mistri 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +355 -2
- data/CONTRIBUTING.md +17 -3
- data/NOTICE +11 -0
- data/README.md +145 -226
- data/UPGRADING.md +810 -0
- data/assets/vendors/README.md +12 -0
- data/assets/vendors/claude-mark.svg +3 -0
- data/assets/vendors/gemini-mark.svg +10 -0
- data/assets/vendors/openai-mark-dark.svg +1 -0
- data/assets/vendors/openai-mark.svg +1 -0
- data/docs/README.md +2 -1
- data/docs/context-and-workspaces.md +84 -13
- data/docs/logging.md +90 -0
- data/docs/mcp.md +762 -21
- data/docs/reliability.md +210 -24
- data/docs/sessions.md +415 -36
- data/docs/sub-agents.md +85 -7
- data/docs/tool-contracts.md +528 -13
- data/examples/approval.rb +7 -7
- data/examples/browser.rb +1 -1
- data/examples/page_editor.rb +2 -2
- data/examples/quickstart.rb +1 -1
- data/lib/generators/mistri/install/templates/migration.rb.tt +4 -2
- data/lib/generators/mistri/mcp/mcp_generator.rb +2 -2
- data/lib/generators/mistri/mcp/templates/model.rb.tt +21 -8
- data/lib/mistri/agent.rb +839 -141
- data/lib/mistri/call_order.rb +137 -0
- data/lib/mistri/child.rb +69 -13
- data/lib/mistri/compaction.rb +200 -35
- data/lib/mistri/compactor/text.rb +91 -0
- data/lib/mistri/compactor.rb +474 -117
- data/lib/mistri/console.rb +44 -11
- data/lib/mistri/content.rb +70 -3
- data/lib/mistri/definition.rb +2 -2
- data/lib/mistri/edit.rb +13 -7
- data/lib/mistri/errors.rb +37 -0
- data/lib/mistri/event.rb +20 -9
- data/lib/mistri/locks/rails_cache.rb +16 -2
- data/lib/mistri/locks.rb +12 -3
- data/lib/mistri/mcp/client.rb +247 -61
- data/lib/mistri/mcp/conversation.rb +161 -0
- data/lib/mistri/mcp/egress.rb +5 -4
- data/lib/mistri/mcp/mirror.rb +90 -0
- data/lib/mistri/mcp/negotiation.rb +222 -0
- data/lib/mistri/mcp/oauth/client_identity.rb +53 -0
- data/lib/mistri/mcp/oauth/tolerance.rb +61 -0
- data/lib/mistri/mcp/oauth.rb +303 -82
- data/lib/mistri/mcp/results.rb +97 -0
- data/lib/mistri/mcp/sdk_client.rb +47 -0
- data/lib/mistri/mcp/wires.rb +325 -52
- data/lib/mistri/mcp.rb +304 -55
- data/lib/mistri/memory.rb +1 -1
- data/lib/mistri/message.rb +45 -8
- data/lib/mistri/models.rb +146 -24
- data/lib/mistri/partial_json.rb +5 -5
- data/lib/mistri/providers/anthropic/assembler.rb +40 -3
- data/lib/mistri/providers/anthropic/serializer.rb +154 -22
- data/lib/mistri/providers/anthropic.rb +77 -12
- data/lib/mistri/providers/fake.rb +4 -1
- data/lib/mistri/providers/gemini/assembler.rb +63 -3
- data/lib/mistri/providers/gemini/serializer.rb +27 -16
- data/lib/mistri/providers/gemini.rb +56 -11
- data/lib/mistri/providers/openai/assembler.rb +36 -5
- data/lib/mistri/providers/openai/serializer.rb +76 -22
- data/lib/mistri/providers/openai.rb +91 -14
- data/lib/mistri/reminder.rb +35 -3
- data/lib/mistri/result.rb +6 -4
- data/lib/mistri/result_limit.rb +164 -0
- data/lib/mistri/sandbox/quickjs.rb +345 -0
- data/lib/mistri/sandbox.rb +18 -0
- data/lib/mistri/schema.rb +26 -2
- data/lib/mistri/scratchpad.rb +107 -0
- data/lib/mistri/session/log.rb +137 -0
- data/lib/mistri/session.rb +405 -75
- data/lib/mistri/sinks/logger.rb +407 -0
- data/lib/mistri/skills.rb +10 -4
- data/lib/mistri/spawner.rb +43 -12
- data/lib/mistri/sse.rb +3 -2
- data/lib/mistri/stores/active_record.rb +30 -6
- data/lib/mistri/stores/jsonl.rb +26 -7
- data/lib/mistri/stores/memory.rb +6 -2
- data/lib/mistri/sub_agent/execution.rb +11 -3
- data/lib/mistri/sub_agent/runtime.rb +11 -1
- data/lib/mistri/sub_agent.rb +13 -4
- data/lib/mistri/tool.rb +71 -7
- data/lib/mistri/tool_arguments.rb +10 -11
- data/lib/mistri/tool_context.rb +15 -3
- data/lib/mistri/tool_executor.rb +49 -26
- data/lib/mistri/tool_result.rb +8 -2
- data/lib/mistri/tool_search/index.rb +193 -0
- data/lib/mistri/tool_search.rb +200 -0
- data/lib/mistri/tools/delete_file.rb +22 -0
- data/lib/mistri/tools/edit_file.rb +24 -14
- data/lib/mistri/tools/find_in_file.rb +1 -0
- data/lib/mistri/tools/grep.rb +212 -0
- data/lib/mistri/tools/list_files.rb +38 -5
- data/lib/mistri/tools/read_file.rb +83 -21
- data/lib/mistri/tools/read_memory.rb +2 -1
- data/lib/mistri/tools/run_code.rb +167 -0
- data/lib/mistri/tools/write_file.rb +66 -9
- data/lib/mistri/tools.rb +72 -1
- data/lib/mistri/transport/streamable_http.rb +140 -0
- data/lib/mistri/transport.rb +53 -63
- data/lib/mistri/usage.rb +33 -4
- data/lib/mistri/version.rb +1 -1
- data/lib/mistri/workspace/active_record.rb +22 -10
- data/lib/mistri/workspace/directory.rb +5 -1
- data/lib/mistri/workspace/memory.rb +4 -0
- data/lib/mistri/workspace/path_space.rb +56 -0
- data/lib/mistri/workspace/single.rb +6 -1
- data/lib/mistri.rb +28 -4
- metadata +30 -2
data/UPGRADING.md
CHANGED
|
@@ -9,6 +9,816 @@ Upgrade a representative application and persisted session set in staging
|
|
|
9
9
|
before production. Do not treat a passing bundle update as a session migration
|
|
10
10
|
test.
|
|
11
11
|
|
|
12
|
+
## From 0.7.x to 0.8.x
|
|
13
|
+
|
|
14
|
+
Most hosts need no code change. Read the points that apply to you.
|
|
15
|
+
|
|
16
|
+
### On Claude, Anthropic writes the summary of a compaction
|
|
17
|
+
|
|
18
|
+
On Anthropic's own origin, for a model its page lists, a compaction now asks
|
|
19
|
+
the API for the summary. Mistri sends its own cut and its own summary prompt.
|
|
20
|
+
|
|
21
|
+
- Most hosts do nothing. The kept turns keep their thinking, and the request
|
|
22
|
+
reads the session's prompt cache.
|
|
23
|
+
- The request sends the beta header `compact-2026-09-04`, and so does every
|
|
24
|
+
later request of that session. A gateway that filters beta headers has to
|
|
25
|
+
let it through, or the host sets `Compaction.new(native: false)`.
|
|
26
|
+
- A host that shows the summary reads it as before, from `event.content` or
|
|
27
|
+
the entry's `"summary"`. It cannot be edited: the API refuses a changed
|
|
28
|
+
block. The entry also holds `"block"` and `"provider"`.
|
|
29
|
+
- The first message of a compacted conversation is then an assistant message
|
|
30
|
+
with one `Content::Compaction` block, where it was a user message with the
|
|
31
|
+
summary. A host that reads `session.messages.first.text` reads nil there.
|
|
32
|
+
- A session whose latest compaction Anthropic wrote does not run on another
|
|
33
|
+
provider. Such a run ends with an error that says so.
|
|
34
|
+
- For the summary Mistri writes itself, set `Compaction.new(native: false)`.
|
|
35
|
+
|
|
36
|
+
### A request that is too long has its own error type, and is recovered once
|
|
37
|
+
|
|
38
|
+
A provider's refusal of an input longer than the model's context window was an
|
|
39
|
+
errored message of the type `ProviderError` on Anthropic and Gemini and
|
|
40
|
+
`InvalidRequestError` on OpenAI. It is now `ContextTooLongError` on all
|
|
41
|
+
three.
|
|
42
|
+
|
|
43
|
+
- A host that reads `message.error["type"]` to recognise this refusal reads
|
|
44
|
+
the new type. `Mistri::ErrorData.too_long?(message.error)` asks the same.
|
|
45
|
+
- An agent with compaction no longer ends the run on this refusal. It compacts
|
|
46
|
+
once and sends the turn again. A host that counted on the error to start
|
|
47
|
+
its own recovery sets `compaction: false` or removes that recovery.
|
|
48
|
+
- `event.reason` of `:compacting`, `:compaction` and `:compaction_failed`,
|
|
49
|
+
and the entry's `"trigger"`, can now be `:overflow`.
|
|
50
|
+
|
|
51
|
+
### On GPT, OpenAI writes the compaction, and nobody can read it
|
|
52
|
+
|
|
53
|
+
On OpenAI's own origin a compaction now ends its request with a trigger, and
|
|
54
|
+
the API returns one sealed item in place of a summary.
|
|
55
|
+
|
|
56
|
+
- A host that shows the summary has nothing to show for these compactions:
|
|
57
|
+
`event.content`, the entry's `"summary"` and `result[:summary]` are nil.
|
|
58
|
+
`event.status` is `:native`. For a summary a person can read, set
|
|
59
|
+
`Compaction.new(native: false)`.
|
|
60
|
+
- `Compaction.new(instructions:)` and `agent.compact(instructions:)` do not
|
|
61
|
+
reach OpenAI's own compaction. They apply to the summary Mistri writes.
|
|
62
|
+
- A session whose latest compaction OpenAI wrote does not run on another
|
|
63
|
+
provider. Only OpenAI can read that item. A later summary that has to be
|
|
64
|
+
asked with Mistri's text, as over the window or from a fallback summarizer,
|
|
65
|
+
first asks OpenAI for the item's text in one small request.
|
|
66
|
+
- With `native: false`, a new compaction on OpenAI puts Mistri's summary
|
|
67
|
+
after the kept turns. A host that reads `session.messages.first` as the
|
|
68
|
+
summary reads the first kept turn there. Sessions compacted before this
|
|
69
|
+
release replay as they did.
|
|
70
|
+
|
|
71
|
+
### An agent's summary request repeats the conversation
|
|
72
|
+
|
|
73
|
+
The request that writes a compaction's summary now holds the agent's system
|
|
74
|
+
prompt, its tools and the messages up to the cut, and ends with the summary
|
|
75
|
+
prompt, as a system message where the provider takes one. Before, it held one
|
|
76
|
+
text and the compactor's own system prompt.
|
|
77
|
+
|
|
78
|
+
- Most hosts do nothing. The request reads the session's prompt cache and
|
|
79
|
+
costs less.
|
|
80
|
+
- The request runs with the thinking or reasoning setting of the agent's
|
|
81
|
+
provider. A host that set a large thinking budget pays for thinking in the
|
|
82
|
+
summary too. `Compaction.new(max_tokens:)` still bounds its output.
|
|
83
|
+
- A custom provider, a gateway or a test that looked for the text
|
|
84
|
+
`<conversation>` in the summary request finds the conversation's own
|
|
85
|
+
messages, and the summary prompt in the last one.
|
|
86
|
+
- A reply that calls a tool is not a summary. The same provider is then asked
|
|
87
|
+
once more, with the text. After any other failure a configured `fallback:`
|
|
88
|
+
is asked with the text, as before.
|
|
89
|
+
|
|
90
|
+
### A compaction keeps what `keep_recent:` says, and the level reads higher
|
|
91
|
+
|
|
92
|
+
The context level and the turns a compaction keeps are now measured from the
|
|
93
|
+
provider's own counts.
|
|
94
|
+
|
|
95
|
+
- A compaction with the default `keep_recent:` of 20,000 keeps about 20,000
|
|
96
|
+
tokens. Before, it kept up to 52,960. A host that wants the larger tail
|
|
97
|
+
raises `keep_recent:`.
|
|
98
|
+
- The level of a session that no provider has answered, and of a session right
|
|
99
|
+
after a compaction, reads higher than before, because it is closer to the
|
|
100
|
+
provider's count. A host that compares `context_usage[:tokens]` with a
|
|
101
|
+
number of its own checks that number.
|
|
102
|
+
- `agent.context_usage` returns three more keys, `estimated`, `threshold` and
|
|
103
|
+
`remaining`. A host that matches the whole hash adds them.
|
|
104
|
+
- `Event` has two more members, `tokens_before` and `tokens_after`, and
|
|
105
|
+
`ToolContext` has one more, `compaction`. A host that builds either with
|
|
106
|
+
positional values, or matches one with a pattern of every member, adds
|
|
107
|
+
them. Keywords are unaffected.
|
|
108
|
+
- Near the threshold a turn can begin with one request to the provider's count
|
|
109
|
+
endpoint. It is free. It takes about 0.1 to 0.5 seconds on Anthropic and
|
|
110
|
+
Google, and about 13 ms for each 1,000 tokens on OpenAI.
|
|
111
|
+
- A compaction keeps no turn that the compaction before it kept, and at most
|
|
112
|
+
half of the room under its threshold. With a low `threshold:`, or with
|
|
113
|
+
compactions close together, it keeps less than `keep_recent:`.
|
|
114
|
+
|
|
115
|
+
### A summary that is not complete is rejected
|
|
116
|
+
|
|
117
|
+
A reply that is empty, cut short or calls a tool is no longer stored as the
|
|
118
|
+
summary of a compaction.
|
|
119
|
+
|
|
120
|
+
- `agent.compact` raises `Mistri::CompactionError` for it. An automatic
|
|
121
|
+
compaction keeps the context as it was and appends a `compaction_failed`
|
|
122
|
+
entry. After three such failures in a row the agent stops trying until a
|
|
123
|
+
compaction succeeds.
|
|
124
|
+
- A provider class of your own returns `stop_reason: :stop`, text that is not
|
|
125
|
+
blank and no tool calls for a summary.
|
|
126
|
+
- The summary request has its own output limit, `Compaction.new(max_tokens:)`,
|
|
127
|
+
16,384 by default. A chat limit of the host no longer cuts a summary.
|
|
128
|
+
|
|
129
|
+
### The cost of some models changed with the vendors' prices
|
|
130
|
+
|
|
131
|
+
- `gpt-5.6-terra` and `gpt-5.6-luna` cost less, as OpenAI now bills them.
|
|
132
|
+
`gpt-5.6-sol` is on OpenAI's promotional price until the end of
|
|
133
|
+
November 30, 2026, Pacific time.
|
|
134
|
+
- `gemini-3.5-flash` is priced as `gemini-3.6-flash`, which is the model that
|
|
135
|
+
answers it.
|
|
136
|
+
- `claude-sonnet-5` keeps its rates. The catalog held an increase from
|
|
137
|
+
September 2026 that Anthropic cancelled, so a cost read since then was too
|
|
138
|
+
high.
|
|
139
|
+
- A host with a cost budget on one of these models reaches it later.
|
|
140
|
+
|
|
141
|
+
### Gemini 4 compacts earlier than Gemini 3
|
|
142
|
+
|
|
143
|
+
Input, thinking and output share the window of a Gemini 4 model. Automatic
|
|
144
|
+
compaction starts at 978,944 tokens on these models. A host that moves a
|
|
145
|
+
session from a Gemini 3 model to a Gemini 4 model does nothing, and sees the
|
|
146
|
+
first compaction earlier.
|
|
147
|
+
|
|
148
|
+
### OpenAI receives the system prompt as a developer message
|
|
149
|
+
|
|
150
|
+
On OpenAI's own origin the system prompt is now the first item of `input`, a
|
|
151
|
+
message with the role `developer`. The request holds no `instructions`.
|
|
152
|
+
|
|
153
|
+
- Most hosts do nothing. On GPT-6.2 the system prompt is read from the cache
|
|
154
|
+
from the second request on. On earlier models the cost does not change.
|
|
155
|
+
- A gateway or a test that reads `instructions` from the request body reads
|
|
156
|
+
the first input item.
|
|
157
|
+
- A session on GPT-6.2 that began on an earlier release loses the reasoning of
|
|
158
|
+
its earlier turns once, on its first request after the upgrade. The stream
|
|
159
|
+
says so with `:thinking_dropped`.
|
|
160
|
+
- Another origin still receives `instructions`. Through a gateway GPT-6.2
|
|
161
|
+
therefore does not cache the system prompt.
|
|
162
|
+
|
|
163
|
+
### A usage dumped with Marshal is not read by an earlier release
|
|
164
|
+
|
|
165
|
+
`Mistri::Usage` now dumps itself in its own form, so that it can carry the
|
|
166
|
+
context of a turn that took several requests. This release reads a dump of an
|
|
167
|
+
earlier one. An earlier release raises `TypeError` on a dump of this one, and
|
|
168
|
+
a `Mistri::Message` holds its usage.
|
|
169
|
+
|
|
170
|
+
- A host that stores sessions through a store does nothing. Stores write JSON.
|
|
171
|
+
- A host that keeps a message, a usage or a run result in a Marshal cache
|
|
172
|
+
clears that cache before it rolls back, and does not run two releases on one
|
|
173
|
+
cache.
|
|
174
|
+
|
|
175
|
+
### A bridged MCP tool has a limit of 300 seconds
|
|
176
|
+
|
|
177
|
+
A tool from `Mistri::MCP.tools` or `Mistri::MCP.bridge` now ends as a tool
|
|
178
|
+
error when one call takes more than 300 seconds in all.
|
|
179
|
+
|
|
180
|
+
- For a server whose calls rightly take longer, pass the seconds:
|
|
181
|
+
`Mistri::MCP.tools(client, timeout: 1800)`.
|
|
182
|
+
- For the earlier behaviour, pass `timeout: nil`.
|
|
183
|
+
|
|
184
|
+
### A key of `gates:` that names no tool raises
|
|
185
|
+
|
|
186
|
+
`Mistri::MCP.tools(client, gates: { "create_issue" => true })` now raises
|
|
187
|
+
`Mistri::ConfigurationError` for a key that names no tool the server lists.
|
|
188
|
+
Before, such a key was ignored and the tool ran with no approval.
|
|
189
|
+
|
|
190
|
+
- Keys are remote names, as strings. A symbol names no tool.
|
|
191
|
+
- A host that passes one hash to several servers gives each server the keys
|
|
192
|
+
of its own tools:
|
|
193
|
+
`gates: GATED.slice(*client.tools.map { |tool| tool["name"] })`.
|
|
194
|
+
- A server that drops or renames a gated tool makes `MCP.tools` raise until
|
|
195
|
+
the hash is changed.
|
|
196
|
+
|
|
197
|
+
### `Mistri::MCP.tools` returns a tool that reads resources
|
|
198
|
+
|
|
199
|
+
For a server that declares resources, `Mistri::MCP.tools` now returns one
|
|
200
|
+
more tool than the server lists: `read_resource`, under the server's prefix.
|
|
201
|
+
|
|
202
|
+
- A host that wants the list as it was passes `resources: false`.
|
|
203
|
+
- A host that passes `allow:` gets the tool only when the list names
|
|
204
|
+
`read_resource`, and `deny:` leaves it out by the same name.
|
|
205
|
+
- A host that gates a server's tools gates this one with
|
|
206
|
+
`gates: { "read_resource" => true }`, or with `needs_approval: true`.
|
|
207
|
+
- A listing stored before this release has no `"resources"` key, so a client
|
|
208
|
+
built from it offers no such tool until the server is listed again.
|
|
209
|
+
- A result that held bytes used to show the line `[resource: uri]`. It now
|
|
210
|
+
shows an image, or the text, or where the bytes were saved.
|
|
211
|
+
|
|
212
|
+
### MCP sign-in checks more, when the host hands it more
|
|
213
|
+
|
|
214
|
+
- Pass the callback's `iss` to `OAuth.complete`: `iss: params[:iss]`. Without
|
|
215
|
+
it nothing changes, and a callback from another authorization server is not
|
|
216
|
+
told apart.
|
|
217
|
+
- A host that matched the text `invalid_grant` in an error message rescues
|
|
218
|
+
`Mistri::MCP::OAuth::InvalidGrantError` instead. The message is unchanged.
|
|
219
|
+
- A host that stores a client it registered and passes it to `OAuth.start`
|
|
220
|
+
with its `issuer:` rescues `Mistri::MCP::OAuth::IssuerChanged`, drops that
|
|
221
|
+
client and starts again without it. Before, the same case raised
|
|
222
|
+
`Mistri::MCP::Error` with the same message.
|
|
223
|
+
- After a 403 whose challenge says `insufficient_scope`, the MCP client raises
|
|
224
|
+
at once. Before, it asked the token callable once more and sent the request
|
|
225
|
+
again. Read the challenge with `OAuth.challenge(error)`.
|
|
226
|
+
- An application generated the connection model from an earlier release keeps
|
|
227
|
+
its copy. To get the lock around the refresh, copy `bearer_token` and
|
|
228
|
+
`stale?` from the new template, and pass `iss:` from the callback.
|
|
229
|
+
- `OAuth.start` returns one more key, `"scope"`.
|
|
230
|
+
|
|
231
|
+
### A bridged MCP tool says which server could not be used
|
|
232
|
+
|
|
233
|
+
- The text of a bridged tool's result changed for a server that cannot be
|
|
234
|
+
used. It names the server by its `prefix:`, and says so when the server
|
|
235
|
+
needs a sign-in. A host that matched the text
|
|
236
|
+
`No connection to the MCP server could be established` matches
|
|
237
|
+
`did not run` instead.
|
|
238
|
+
- `Client#call_tool` raises a `Mistri::ProviderError` tagged
|
|
239
|
+
`Mistri::MCP::NotSent` when no connection could be opened. Before, it raised
|
|
240
|
+
`Mistri::AmbiguousDeliveryError`, which says the call may have completed.
|
|
241
|
+
|
|
242
|
+
### A bridged MCP tool's description is cut at 4,096 characters
|
|
243
|
+
|
|
244
|
+
A longer description now reaches the model cut, with a line that says so.
|
|
245
|
+
Pass `description_limit: nil` to `Mistri::MCP.tools` for the earlier
|
|
246
|
+
behaviour, or another number.
|
|
247
|
+
|
|
248
|
+
### The MCP client asks a server which revision it speaks
|
|
249
|
+
|
|
250
|
+
The client now sends `server/discover` before its first request, and uses the
|
|
251
|
+
2026-07-28 form with a server that offers it.
|
|
252
|
+
|
|
253
|
+
- A server that speaks only an older revision gets one request more when a
|
|
254
|
+
client first connects. Store `client.listing` and build clients from it:
|
|
255
|
+
such a client asks nothing.
|
|
256
|
+
- `client.listing` has a new key, `"protocolVersion"`. A listing stored
|
|
257
|
+
before this release still works, and its client asks once.
|
|
258
|
+
- A server that offers 2026-07-28 gets no `initialize` and no session. A host
|
|
259
|
+
that reads `client.server_info` on a client built from a stored listing
|
|
260
|
+
gets nil, because nothing was asked.
|
|
261
|
+
- Over HTTP in the 2026-07-28 form, a direct `Client#call_tool` on a client
|
|
262
|
+
that holds no listing lists the tools first.
|
|
263
|
+
- `Mistri::MCP::Client::PROTOCOL_VERSION` is `"2026-07-28"`. The revision the
|
|
264
|
+
handshake offers is still 2025-11-25.
|
|
265
|
+
|
|
266
|
+
### MCP over HTTP keeps a session and ends it
|
|
267
|
+
|
|
268
|
+
- `Client#close` now sends a DELETE with the session id. A server that counts
|
|
269
|
+
on sessions being left open sees them end.
|
|
270
|
+
- After a failed call the next call uses the same session. Before, the client
|
|
271
|
+
did the handshake again.
|
|
272
|
+
- A timeout of a list raises `Mistri::MCP::Error`. Before, it raised
|
|
273
|
+
`Mistri::ProviderError`. Both are a `Mistri::Error`.
|
|
274
|
+
- The message of an HTTP error from an MCP server changed. A host that matched
|
|
275
|
+
the text `provider request failed` matches the class or `status` instead.
|
|
276
|
+
- A 401 or 403 from an MCP server is still a `Mistri::AuthenticationError`.
|
|
277
|
+
Its message now says that the MCP server did not authorize the request,
|
|
278
|
+
where it read "invalid or missing API key".
|
|
279
|
+
- `headers:` no longer takes `Last-Event-ID`, `Mcp-Method` or `Mcp-Name`.
|
|
280
|
+
- `read_timeout` is now the wait for one message. A call that takes longer
|
|
281
|
+
than `read_timeout`, 120 seconds unless the host set another, on a server
|
|
282
|
+
that sends only comments to keep its stream open, now ends at
|
|
283
|
+
`read_timeout` with `Mistri::AmbiguousDeliveryError`. Before, each comment
|
|
284
|
+
started the wait again and the call returned its answer. Pass a longer
|
|
285
|
+
`read_timeout`, or `progress: true` for a server that reports progress,
|
|
286
|
+
because a progress notice is a message.
|
|
287
|
+
|
|
288
|
+
### A timeout no longer ends a stdio MCP server
|
|
289
|
+
|
|
290
|
+
When `read_timeout` passes, the client cancels that one request and keeps the
|
|
291
|
+
server. Before, the server was ended and the next call started a new one.
|
|
292
|
+
|
|
293
|
+
- After a request with no answer, the client asks the server for a sign of
|
|
294
|
+
life before the next request. A server that gives none is ended, and the
|
|
295
|
+
request starts a new one.
|
|
296
|
+
- A server that answers that question and still never answers a call is kept.
|
|
297
|
+
A host that relied on a new server after every timeout calls
|
|
298
|
+
`client.close` itself. The next call then starts one.
|
|
299
|
+
- A line on a stdio server's stdout that is not JSON no longer fails the call.
|
|
300
|
+
It is written to standard error with the prefix `mistri:`.
|
|
301
|
+
- `client.close` takes up to half a second longer for a stdio server that does
|
|
302
|
+
not end when its input closes.
|
|
303
|
+
|
|
304
|
+
### The calls of a turn run in the order written
|
|
305
|
+
|
|
306
|
+
A tool used to run at the same time as the other calls of its turn. It now
|
|
307
|
+
runs alone, in its place, unless it is marked.
|
|
308
|
+
|
|
309
|
+
- Mark each tool of yours that only reads:
|
|
310
|
+
`Mistri::Tool.define(name, description, parallel: true)`. Until then a turn
|
|
311
|
+
of several of them runs one call at a time, and one that fails holds back
|
|
312
|
+
the calls after it.
|
|
313
|
+
- A call written after a call that is not marked and failed, was refused or
|
|
314
|
+
was blocked is no longer run. It answers `Not run: ...`, and the model sends
|
|
315
|
+
it again.
|
|
316
|
+
- A call written after a call that waits for approval is no longer run before
|
|
317
|
+
the decision, whether it is marked or not. It answers `Not run: ...`, and
|
|
318
|
+
the model sends it again once the person has decided. One that needs
|
|
319
|
+
approval itself waits with it, unless a call that is not marked and does not
|
|
320
|
+
wait comes between them. Before, every such call ran at once. For a
|
|
321
|
+
Gemini turn whose calls carry no IDs, a call that needs approval does not
|
|
322
|
+
wait when a later call of the same name is answered before it: it answers
|
|
323
|
+
with an error, and the model sends the calls again.
|
|
324
|
+
- `MCP.tools` marks a tool that its server lists with `readOnlyHint: true`.
|
|
325
|
+
Pass `parallel: false` for a server whose hints you do not trust, or a hash
|
|
326
|
+
by remote name for single tools, such as a tool that only waits.
|
|
327
|
+
- A call that runs by itself now runs on the thread that called the agent,
|
|
328
|
+
not on a thread of its own. What its handler sets on the thread stays set
|
|
329
|
+
after the run, and a `throw` to a `catch` around the run now ends the run.
|
|
330
|
+
Inside a Rails job or request it sees the `Current` attributes set there,
|
|
331
|
+
it uses that thread's database connection and any transaction open on it,
|
|
332
|
+
and an error it raises is no longer reported to `Rails.error` on its way to
|
|
333
|
+
becoming a tool result.
|
|
334
|
+
- A host that set `max_concurrency: 1` to get order can drop it.
|
|
335
|
+
|
|
336
|
+
### A tool's image reaches GPT and Gemini models
|
|
337
|
+
|
|
338
|
+
A tool result that holds an image used to reach an OpenAI or Gemini model as
|
|
339
|
+
its text and the line `[1 non-text block(s) omitted]`. The image is now sent.
|
|
340
|
+
|
|
341
|
+
- Every request that carries the result costs the image's tokens. A session
|
|
342
|
+
with many screenshots costs more on these providers than it did.
|
|
343
|
+
- Another origin of the OpenAI provider receives the image the same way, as
|
|
344
|
+
an array in the output of the function call, and must take one.
|
|
345
|
+
|
|
346
|
+
### An image Anthropic or OpenAI would refuse is sent as text
|
|
347
|
+
|
|
348
|
+
Anthropic and OpenAI take PNG, JPEG, GIF and WebP. An image of another format
|
|
349
|
+
in a tool result or a user turn ended the request, and every request of the
|
|
350
|
+
session after it. Both providers are now sent an image by its first bytes: one
|
|
351
|
+
of the four formats with the type its bytes show, and any other image as a
|
|
352
|
+
line of text that says an image was not sent and why.
|
|
353
|
+
|
|
354
|
+
- A host that drops such an image in `after_tool` or `transform_context:`
|
|
355
|
+
only to keep the session going can stop. A host that converts one should
|
|
356
|
+
keep doing so: the model sees the converted picture, and only a line of text
|
|
357
|
+
without it.
|
|
358
|
+
- A session that such an image ended works again from its next request.
|
|
359
|
+
Nothing stored changes.
|
|
360
|
+
- A model on these two providers no longer receives an image whose bytes are
|
|
361
|
+
not one of the four formats, whatever its label says. That holds for every
|
|
362
|
+
origin of the two providers.
|
|
363
|
+
- An image whose label is not the type its bytes show, such as `image/jpg` or
|
|
364
|
+
a JPEG labelled `image/png`, is sent with its real type. Anthropic refused
|
|
365
|
+
both. An MCP server that names no type for a JPEG produced the second.
|
|
366
|
+
OpenAI took both, so a stored request that holds one differs once from the
|
|
367
|
+
request sent before and can miss the prompt cache once.
|
|
368
|
+
- A session that moves to one of these two providers from a provider that
|
|
369
|
+
took the image goes on, where it was refused. The model there is not sent
|
|
370
|
+
the image, and when asked about it can say that an earlier answer about it
|
|
371
|
+
was a guess.
|
|
372
|
+
- An image over a provider's size limits is still refused, and so is one whose
|
|
373
|
+
data is broken. The refusal still ends the session. Make a large image
|
|
374
|
+
smaller in `after_tool`.
|
|
375
|
+
|
|
376
|
+
### An image holds strict base64
|
|
377
|
+
|
|
378
|
+
`Content::Image` kept the base64 text it was given. Every provider refuses
|
|
379
|
+
base64 with line breaks, which is what `Base64.encode64` writes, and
|
|
380
|
+
Anthropic and OpenAI also refuse base64 without padding or in the URL-safe
|
|
381
|
+
alphabet. One such image ended the session. An image now holds strict base64,
|
|
382
|
+
whatever form it was built from.
|
|
383
|
+
|
|
384
|
+
- Nothing to change. `Content::Image.new(data: Base64.encode64(bytes), ...)`
|
|
385
|
+
now works.
|
|
386
|
+
- `image.data` is the strict form, so it can differ from the text the image
|
|
387
|
+
was built from. `image.bytes` used to raise for those forms and now works.
|
|
388
|
+
- A session that such an image ended works again when it is read. The stored
|
|
389
|
+
entry is not rewritten.
|
|
390
|
+
- An image from an MCP server whose data is in the URL-safe alphabet used to
|
|
391
|
+
be damaged on its way in. It is now read as the server meant it.
|
|
392
|
+
- Building an image checks its data, at about 0.4 ms for each megabyte. A
|
|
393
|
+
session builds its messages again from the stored entries for each request,
|
|
394
|
+
so a request costs about 1 ms more for each megabyte of images the session
|
|
395
|
+
holds. An image stored in another form is written again each time, at about
|
|
396
|
+
4 ms for each megabyte.
|
|
397
|
+
|
|
398
|
+
### Gemini 2.5 models are removed
|
|
399
|
+
|
|
400
|
+
Google retired `gemini-2.5-pro` and `gemini-2.5-flash`. The catalog no longer
|
|
401
|
+
lists them.
|
|
402
|
+
|
|
403
|
+
- Name a current model, for example `gemini-3.8-flash`.
|
|
404
|
+
- An agent with a cost budget on a 2.5 model now raises
|
|
405
|
+
`Mistri::ConfigurationError` when you build it.
|
|
406
|
+
|
|
407
|
+
### Provider defaults changed
|
|
408
|
+
|
|
409
|
+
A provider built without `model:` now uses `claude-opus-5-5`, `gpt-6.1-sol`, or
|
|
410
|
+
`gemini-3.8-flash`.
|
|
411
|
+
|
|
412
|
+
- Pass `model:` to keep an earlier model.
|
|
413
|
+
|
|
414
|
+
### Stdio MCP servers no longer inherit the host environment
|
|
415
|
+
|
|
416
|
+
A stdio MCP server used to get every variable the host process had, provider
|
|
417
|
+
keys included. It now gets `env:` and a fixed list: identity and `PATH`,
|
|
418
|
+
RubyGems paths, locale and temp files, and CA bundle paths. `docs/mcp.md` names
|
|
419
|
+
each variable.
|
|
420
|
+
|
|
421
|
+
- Pass a variable the server relied on through `env:`. For example,
|
|
422
|
+
`env: ENV.slice("HTTPS_PROXY", "NO_PROXY")` forwards the proxy settings.
|
|
423
|
+
- A Ruby server no longer runs inside the host's bundle. Start it with
|
|
424
|
+
`bundle exec` if it needs the host's gems, and pass Bundler settings the
|
|
425
|
+
host keeps in its environment, such as `BUNDLE_PATH`, through `env:`.
|
|
426
|
+
- `env: ENV.to_h` passes the whole environment, as before.
|
|
427
|
+
|
|
428
|
+
### A bridged MCP tool may get another name
|
|
429
|
+
|
|
430
|
+
`MCP.tools` and `MCP.bridge` now give a tool a name every provider takes:
|
|
431
|
+
letters, digits, underscores and hyphens, 64 characters at most, not starting
|
|
432
|
+
with a digit or a hyphen. The whole name decides: the prefix, two underscores
|
|
433
|
+
and the remote name, or the remote name alone. One inside that set is
|
|
434
|
+
unchanged.
|
|
435
|
+
|
|
436
|
+
- Any other changes, even where your one provider took it: a dot or a colon
|
|
437
|
+
on Gemini, a leading digit or more than 64 characters on Anthropic. The new
|
|
438
|
+
name ends in a short hash of the whole name.
|
|
439
|
+
- The remote name alone does not tell you. `9lives` under the prefix
|
|
440
|
+
`tracker` stays `tracker__9lives`, and `read` under a prefix with a dot, or
|
|
441
|
+
a long one, changes.
|
|
442
|
+
- `Mistri::MCP.local_name(remote, prefix)` gives the new name, for a host that
|
|
443
|
+
stored the old one.
|
|
444
|
+
- To keep a name of your own, bridge that tool with
|
|
445
|
+
`MCP.bridge(client, definition, name: "yours")`. That name is used as
|
|
446
|
+
given, so it has to be one your provider takes.
|
|
447
|
+
- `allow:`, `deny:` and `gates:` still go by the remote name.
|
|
448
|
+
|
|
449
|
+
### `MCP.tools` leaves out a tool it cannot bridge
|
|
450
|
+
|
|
451
|
+
A tool whose schema Mistri cannot validate, or whose name the server lists
|
|
452
|
+
twice, is left out, and the rest of the server is bridged. Before,
|
|
453
|
+
`MCP.tools` raised for the whole list.
|
|
454
|
+
|
|
455
|
+
- The tool and the reason go to a warning, or to the block when you pass one.
|
|
456
|
+
Raise from the block to fail as before.
|
|
457
|
+
- `MCP.bridge` still raises for the one definition it is given.
|
|
458
|
+
|
|
459
|
+
### A session can hold a system message
|
|
460
|
+
|
|
461
|
+
An agent appends a system message with `reminder` set to the session when it
|
|
462
|
+
holds a deferred tool, and when a tool was bridged from an MCP server that
|
|
463
|
+
sends instructions. Mistri wrote it for the model. It is not the user's
|
|
464
|
+
message.
|
|
465
|
+
|
|
466
|
+
- Allow the `system` role where code reads `Session#messages` by role. In a
|
|
467
|
+
view that shows a conversation to a person, leave out a message whose
|
|
468
|
+
`reminder` is set.
|
|
469
|
+
- Keep these messages in a `transform_context` lambda. One that drops them
|
|
470
|
+
takes the list of deferred tools and the servers' instructions away from the
|
|
471
|
+
model.
|
|
472
|
+
- A provider class of your own needs no change. It is given each one as a user
|
|
473
|
+
message whose text is in a system-reminder block.
|
|
474
|
+
|
|
475
|
+
### An MCP server's instructions reach the model
|
|
476
|
+
|
|
477
|
+
A server may send `instructions` in its initialize result. `MCP.tools` now
|
|
478
|
+
sets that text on every tool it bridges, and an agent appends it to the
|
|
479
|
+
conversation, cut at 2,000 bytes for each server. It is appended with the
|
|
480
|
+
agent's first request. When the instructions of all servers are more than
|
|
481
|
+
20,000 bytes together, those of a server whose tools are all deferred are
|
|
482
|
+
appended once one of its tools is loaded. On an earlier release the model
|
|
483
|
+
received none of it.
|
|
484
|
+
|
|
485
|
+
- Read what each server sends with `client.instructions` before you upgrade.
|
|
486
|
+
- Pass `instructions: false` to `MCP.tools` to leave a server's instructions
|
|
487
|
+
out, or a string to send your own text in their place.
|
|
488
|
+
- A session from before the upgrade gets the message appended on its next run,
|
|
489
|
+
by the same rule.
|
|
490
|
+
|
|
491
|
+
### Blank input raises
|
|
492
|
+
|
|
493
|
+
`Agent#run` and `Session#steer` now raise `ArgumentError` for text that is
|
|
494
|
+
empty or only whitespace. Before, `run` sent whitespace to the provider, and
|
|
495
|
+
`steer` accepted any text.
|
|
496
|
+
|
|
497
|
+
- Check the text before you call them, or rescue `ArgumentError`. `Child#say`
|
|
498
|
+
raises the same way.
|
|
499
|
+
- `run` still accepts images with no text. `task` is unchanged.
|
|
500
|
+
|
|
501
|
+
### The JSONL store checks session ids
|
|
502
|
+
|
|
503
|
+
`Mistri::Stores::JSONL` now raises `ArgumentError` for a session id that holds
|
|
504
|
+
a character outside `A-Z`, `a-z`, `0-9`, `_`, and `-`, or is longer than 249
|
|
505
|
+
characters. Before, it replaced every other character with `-`, so two ids
|
|
506
|
+
could share one file.
|
|
507
|
+
|
|
508
|
+
- To keep an existing session, use its id with each other character replaced
|
|
509
|
+
by `-`. That is the name of its file: `user:42` is stored as `user-42`.
|
|
510
|
+
- New session files are created with mode 0600. Existing files keep their
|
|
511
|
+
mode.
|
|
512
|
+
|
|
513
|
+
### A session reads only what is new
|
|
514
|
+
|
|
515
|
+
A session reads its log from the store once and then asks only for the entries
|
|
516
|
+
appended since. The built-in stores support this. A custom store keeps working
|
|
517
|
+
unchanged: without `settled?` it is read whole on every read, as before.
|
|
518
|
+
|
|
519
|
+
- To let a session read a custom store in part, add `load(id, from: 0)` and
|
|
520
|
+
`settled?` as [Sessions and control](docs/sessions.md#reading-only-what-is-new)
|
|
521
|
+
describes.
|
|
522
|
+
- A subclass of a built-in store, or a wrapper that forwards every method,
|
|
523
|
+
already answers `settled?`. Its own `load` must take `from:`.
|
|
524
|
+
- Inside a transaction that Active Record opened, a session reads fresh and
|
|
525
|
+
holds nothing, so what it answers there is unchanged. A transaction begun
|
|
526
|
+
with raw SQL is invisible to the store; do not read a session inside one.
|
|
527
|
+
- The Active Record store raises `Mistri::ConfigurationError` when the rows it
|
|
528
|
+
reads are not at consecutive positions. Rows that are only ever appended sit
|
|
529
|
+
at positions 1, 2, 3. Delete a session's rows together, never some of them.
|
|
530
|
+
- The Active Record store needs READ COMMITTED or a stronger isolation level
|
|
531
|
+
on the connection that reads. MySQL and PostgreSQL have that by default.
|
|
532
|
+
- A `Session` object holds the entries of its window in memory, image data
|
|
533
|
+
included, for as long as the object lives. After a session's rows are
|
|
534
|
+
deleted, build a new `Session` object. A `Child` holds every entry of its
|
|
535
|
+
worker's log the same way.
|
|
536
|
+
|
|
537
|
+
### A session starts at its newest checkpoint
|
|
538
|
+
|
|
539
|
+
A compaction now carries what a turn needs from before it, and a session
|
|
540
|
+
reads, replays and audits from the newest one on, however long its log is. A
|
|
541
|
+
compaction written before this release carries nothing, so such a session is
|
|
542
|
+
read whole until its next compaction.
|
|
543
|
+
|
|
544
|
+
- A tool call id must be unique within the session's window, the entries from
|
|
545
|
+
the newest checkpoint's `kept_from` on. It used to be unique over the whole
|
|
546
|
+
session.
|
|
547
|
+
- `approve` and `deny` repeated for a call that was settled before the newest
|
|
548
|
+
checkpoint raise `Mistri::ConfigurationError` ("no open approval"). They
|
|
549
|
+
used to return nil.
|
|
550
|
+
- An entry older than the window is no longer replayed or audited as a
|
|
551
|
+
message. A store may still decode it while the window is being found.
|
|
552
|
+
- To let a session find its window in a custom store without loading the
|
|
553
|
+
rest, add `size(id)` and take `to:` in `load`, as
|
|
554
|
+
[Sessions and control](docs/sessions.md#starting-at-the-newest-checkpoint)
|
|
555
|
+
describes. Without them the store is read whole, as before.
|
|
556
|
+
- A subclass of the memory or Active Record store, or a wrapper that forwards
|
|
557
|
+
every method, already answers `size`. Its own `load` must take `to:` as
|
|
558
|
+
well as `from:`.
|
|
559
|
+
- An `approval_decision` entry now records `request`, the position of the
|
|
560
|
+
approval request it answers, and applies only to that request. Decisions
|
|
561
|
+
written earlier have no `request` and keep working as before.
|
|
562
|
+
- Code that appends a compaction entry itself should call
|
|
563
|
+
`Session#checkpoint(summary:, kept_from:)`, so the entry carries what is
|
|
564
|
+
needed from before it. The start must be a user message, an assistant turn
|
|
565
|
+
that calls tools, or the end of the log. It raises
|
|
566
|
+
`Mistri::ConfigurationError` for any other start, and for one that would
|
|
567
|
+
move back or pass an open approval or a steer or report not folded in yet.
|
|
568
|
+
A compaction appended with `Session#append` still replays correctly, and
|
|
569
|
+
the session is read whole while it is the newest one.
|
|
570
|
+
|
|
571
|
+
### A session's string id is fixed
|
|
572
|
+
|
|
573
|
+
`Session.new` keeps its own copy of a string id, and `Session#id` returns a
|
|
574
|
+
copy. Changing either string in place no longer changes which session is read
|
|
575
|
+
and written. Build a new `Session` to work with another id. An id that is not
|
|
576
|
+
a string is kept as the object it was given. A `Child` treats its `session_id`
|
|
577
|
+
the same way.
|
|
578
|
+
|
|
579
|
+
### The generated session table has one index
|
|
580
|
+
|
|
581
|
+
The install generator no longer adds an index on `session_id` alone. The
|
|
582
|
+
unique index on `[session_id, position]` serves every query the store sends,
|
|
583
|
+
and a read or a delete of a whole session.
|
|
584
|
+
|
|
585
|
+
An existing table keeps working as it is. Removing the extra index is
|
|
586
|
+
optional:
|
|
587
|
+
|
|
588
|
+
```ruby
|
|
589
|
+
remove_index :agent_entries, :session_id
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
It saves the storage of that index: about half of the table's secondary index
|
|
593
|
+
size on MySQL 8.4 and a fifth on PostgreSQL 14, measured on 220,000 rows. The
|
|
594
|
+
measured time of an append was unchanged. Keep the index if your own queries
|
|
595
|
+
on the table use it.
|
|
596
|
+
|
|
597
|
+
### The single-value workspace recipe borrows its connection
|
|
598
|
+
|
|
599
|
+
The recipe for `Mistri::Workspace::Single` asked
|
|
600
|
+
`page.class.connection.transaction_open?`. On Rails 7.2 and later, asking a
|
|
601
|
+
model for its connection keeps that connection checked out until the job ends.
|
|
602
|
+
If you copied the recipe, borrow the connection instead:
|
|
603
|
+
|
|
604
|
+
```ruby
|
|
605
|
+
page.class.connection_pool.with_connection(&:transaction_open?)
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
The Active Record workspace and session store need no change in your code.
|
|
609
|
+
|
|
610
|
+
### One runner per session is checked
|
|
611
|
+
|
|
612
|
+
Only when `Mistri.locks` is set:
|
|
613
|
+
|
|
614
|
+
- A second concurrent `run`, `resume`, `task`, or `compact` raises
|
|
615
|
+
`Mistri::SessionBusyError`. Retry, or report the session busy.
|
|
616
|
+
- So does a call back into a running session. From an event subscriber the
|
|
617
|
+
error reaches the host. From a tool it comes back to the model as that
|
|
618
|
+
tool's error and the run goes on.
|
|
619
|
+
- After a crash, runs can raise it for up to three minutes. So can runs after
|
|
620
|
+
a failed release.
|
|
621
|
+
- When the lock backend is down, a top-level run warns and goes ahead without
|
|
622
|
+
its lease. A sub-agent still fails with a report, as before.
|
|
623
|
+
- A session has one lease. Pass `lease: false` to `Agent.new` when your own
|
|
624
|
+
code already holds a lock for the session.
|
|
625
|
+
- `Locks::RailsCache` on a null cache store, the Rails default in development
|
|
626
|
+
and test, grants every lease, so two runs can write one session. Mistri now
|
|
627
|
+
warns when it is given one. Give the adapter a real store there too.
|
|
628
|
+
- `Locks::RailsCache` raises `Mistri::Error` when a cache write fails. Before,
|
|
629
|
+
an outage read as a lease that another runner held.
|
|
630
|
+
|
|
631
|
+
### The retry note names the failure
|
|
632
|
+
|
|
633
|
+
The `:retry` event's `content` and the run log now read "attempt 1 failed
|
|
634
|
+
(OverloadedError 529); retrying in 0.9s". Before, they read "attempt 1 failed;
|
|
635
|
+
retrying in 0.9s".
|
|
636
|
+
|
|
637
|
+
- Code that matches the old text follows. `attempt`, `max_attempts` and
|
|
638
|
+
`delay` on the event are unchanged.
|
|
639
|
+
|
|
640
|
+
### OpenAI tools are no longer strict
|
|
641
|
+
|
|
642
|
+
Mistri sends `strict: false` with every OpenAI tool. Before, the model wrote a
|
|
643
|
+
value into every optional field, for example `""`, `0`, or `[]`.
|
|
644
|
+
|
|
645
|
+
- Remove code that ignores those made-up values.
|
|
646
|
+
- Mistri still validates arguments against your schema before the handler runs.
|
|
647
|
+
|
|
648
|
+
### A changed prompt costs thinking, not the session
|
|
649
|
+
|
|
650
|
+
Current Claude models reject earlier thinking when the system prompt or a tool
|
|
651
|
+
definition changes. Mistri now asks the API to drop that thinking, and the
|
|
652
|
+
request succeeds.
|
|
653
|
+
|
|
654
|
+
- Keep the system prompt and tool definitions stable during a session. The
|
|
655
|
+
model repeats dropped reasoning, which costs output tokens.
|
|
656
|
+
- Handle the new `:thinking_dropped` event to see when this happens. The run
|
|
657
|
+
log prints a warning.
|
|
658
|
+
- Mistri sends the control only to `api.anthropic.com`. For another `origin:`,
|
|
659
|
+
set it yourself:
|
|
660
|
+
|
|
661
|
+
```ruby
|
|
662
|
+
Mistri.agent(
|
|
663
|
+
"claude-opus-5-5",
|
|
664
|
+
provider_options: {
|
|
665
|
+
origin: gateway_url,
|
|
666
|
+
thinking: { type: "adaptive", display: "summarized",
|
|
667
|
+
block_binding: { prefix_mismatch_behavior: "drop_block" } },
|
|
668
|
+
},
|
|
669
|
+
)
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
### An empty completion after text ends the turn
|
|
673
|
+
|
|
674
|
+
A model that has written to the user and then called a tool often answers the
|
|
675
|
+
tool's result with an empty completion. 0.7.0 sent the same request up to
|
|
676
|
+
three more times. The turn now ends there.
|
|
677
|
+
|
|
678
|
+
- `result.text` of such a run reads the text the model wrote before the tool
|
|
679
|
+
call, which `result.said` holds. It read the empty final message before. A
|
|
680
|
+
host that shows the streamed text and then adds `result.text` reads
|
|
681
|
+
`result.message.text` for the final message alone.
|
|
682
|
+
- An empty completion is still retried while the model has written no text
|
|
683
|
+
since the user's last message.
|
|
684
|
+
|
|
685
|
+
### A gated tool tells the model
|
|
686
|
+
|
|
687
|
+
The description a provider receives for a tool with `needs_approval` now ends
|
|
688
|
+
with "A person reviews each call before it runs." `Tool#description` returns
|
|
689
|
+
your text unchanged.
|
|
690
|
+
|
|
691
|
+
- Remove the same sentence from your own descriptions.
|
|
692
|
+
|
|
693
|
+
### The document tools changed
|
|
694
|
+
|
|
695
|
+
`Mistri::Tools.files` returns `read_file`, `write_file`, `edit_file`, `grep`,
|
|
696
|
+
`list_files` and `delete_file`.
|
|
697
|
+
|
|
698
|
+
- `find_in_file` is not among them. A host that names its tools one by one,
|
|
699
|
+
in a definition or a list, names `grep` instead. `Mistri::Tools.find_in_file`
|
|
700
|
+
still builds the old tool for a host that adds it itself.
|
|
701
|
+
- `delete_file` is new. Leave it out of the tools you pass when the model
|
|
702
|
+
must not delete.
|
|
703
|
+
- An agent refuses two tools of one name when it is built. A tool of your own
|
|
704
|
+
named `grep` or `delete_file`, passed beside `Tools.files`, now raises
|
|
705
|
+
"duplicate tool names: grep". Rename yours, or leave the built-in one out.
|
|
706
|
+
- `write_file` no longer replaces a document blindly. To replace one that
|
|
707
|
+
exists the model passes `if_version`, which `read_file`, `write_file` and
|
|
708
|
+
`edit_file` state in their results. A prompt that tells the model to
|
|
709
|
+
overwrite a document should say to read it first, or to edit it.
|
|
710
|
+
- The text of the results changed. `read_file` begins with the path, the
|
|
711
|
+
version and the range, `list_files` adds each size, and `edit_file` ends
|
|
712
|
+
with the new version. Code that reads these texts follows.
|
|
713
|
+
- A custom workspace needs no change. Add `sizes(prefix = nil)`, a Hash of
|
|
714
|
+
path to bytes, to have `list_files` show sizes.
|
|
715
|
+
- `list_files` shows 200 paths at most and says how many it left out. It
|
|
716
|
+
listed every path before.
|
|
717
|
+
- `Mistri::Tools.numbered_window` and `Mistri::Tools::MAX_READ_CHARS` are
|
|
718
|
+
gone. `read_file` sizes a part in bytes, by `MAX_READ_BYTES`.
|
|
719
|
+
|
|
720
|
+
### A large tool result is cut
|
|
721
|
+
|
|
722
|
+
A result over 50,000 bytes is stored as its start and one line that states its
|
|
723
|
+
true size, and the results that answer one assistant message share 200,000
|
|
724
|
+
bytes. Before, every result was stored whole, and one larger than the model's
|
|
725
|
+
window left the session unusable.
|
|
726
|
+
|
|
727
|
+
- The rest of a cut result is not kept anywhere. Give a tool that can return
|
|
728
|
+
more than the limit a way to ask for less, such as a page or a filter. The
|
|
729
|
+
line the model reads asks it to call the tool again for the part it needs.
|
|
730
|
+
- `after_tool` still receives the whole result. A host that keeps large
|
|
731
|
+
results itself does it there.
|
|
732
|
+
- A tool message may hold `cut`, the true bytes and lines. Code that reads
|
|
733
|
+
session messages can show it. No provider is sent it.
|
|
734
|
+
- The `:tool_result` event and its message carry the stored text. A host that
|
|
735
|
+
shows or saves tool output from the event gets the cut result. A view of its
|
|
736
|
+
own can travel in `ui`, which is never cut.
|
|
737
|
+
- Pass `result_limit: Mistri::ResultLimit.new(bytes:, turn_bytes:)` for other
|
|
738
|
+
numbers. `result_limit: false` stores every result whole, as before.
|
|
739
|
+
- A background child takes `result_limit:` on its `Runtime`.
|
|
740
|
+
|
|
741
|
+
### A path from the model is checked
|
|
742
|
+
|
|
743
|
+
The document tools refuse a path that is not plain and relative before any
|
|
744
|
+
workspace is asked: one that starts with `/`, holds an empty part, `.` or
|
|
745
|
+
`..`, a backslash or a control character, or is longer than 512 bytes.
|
|
746
|
+
|
|
747
|
+
- A document stored under such a path, as `/index.html` could be on the
|
|
748
|
+
memory and Active Record workspaces, is no longer reachable through the
|
|
749
|
+
tools. Rename it.
|
|
750
|
+
- The model reads why a path was refused and sends a relative one.
|
|
751
|
+
|
|
752
|
+
### A scratchpad keeps what a cut would lose
|
|
753
|
+
|
|
754
|
+
Nothing changes until you pass `scratchpad:` to an agent.
|
|
755
|
+
|
|
756
|
+
- Pass a workspace scoped to the session. On the Active Record workspace that
|
|
757
|
+
is the same table with the session in the scope.
|
|
758
|
+
- If you pass your own document tools, bind them to the same workspace, so
|
|
759
|
+
the path in a stored result is one the model can read. If you pass none,
|
|
760
|
+
the agent adds all six, and they reach every path of that workspace, not
|
|
761
|
+
only `scratchpad/`.
|
|
762
|
+
- A path under `scratchpad/` belongs to the agent. `write_file`, `edit_file`
|
|
763
|
+
and `delete_file` refuse `scratchpad/tool-results/`.
|
|
764
|
+
- A session with a scratchpad holds a system message with `reminder` set to
|
|
765
|
+
`scratchpad`. Leave it out of a view for a person, as with the others. It
|
|
766
|
+
follows the user's first message, so a test that expects the user's message
|
|
767
|
+
last in the first request reads the last user message instead.
|
|
768
|
+
- A result over its limit is stored as its first 2,000 bytes and the path of
|
|
769
|
+
the whole, where an agent with no scratchpad keeps 50,000 bytes.
|
|
770
|
+
- Saved results are rows the host owns. Delete them with the session.
|
|
771
|
+
|
|
772
|
+
### Code the model writes
|
|
773
|
+
|
|
774
|
+
Nothing changes until you pass `sandbox:` to an agent.
|
|
775
|
+
|
|
776
|
+
- Add the `wasmtime` gem, require `mistri/sandbox/quickjs`, and keep the file
|
|
777
|
+
`quickjs.wasm` of the npm package `quickjs-wasi` 3.7.0 with your
|
|
778
|
+
application. Build one adapter for the process. On a server that forks its
|
|
779
|
+
workers, build it before the fork and run code only in the workers.
|
|
780
|
+
- An event subscriber sees `:tool_started` and `:tool_result` for calls the
|
|
781
|
+
code makes. Their call ids begin with `code_`, and their `message` is not
|
|
782
|
+
among the session's messages. Both events carry the short copy that is
|
|
783
|
+
stored: 2,000 bytes of the call's arguments, and the first 2,000 bytes of
|
|
784
|
+
the result with the true size in the message's `cut`. The whole of both
|
|
785
|
+
went to the tool and to the code.
|
|
786
|
+
- A session holds entries of type `code_call`. Code that reads
|
|
787
|
+
`Session#entries` by type leaves them out of a transcript for a person, or
|
|
788
|
+
shows them under the `run_code` call they belong to. An entry keeps 2,000
|
|
789
|
+
bytes of the call's arguments, and the first 2,000 bytes of its result with
|
|
790
|
+
the true size, and not the result's `ui`, which the `:tool_result` event
|
|
791
|
+
carries. One run stores its first 100 calls. The events are emitted for
|
|
792
|
+
every call.
|
|
793
|
+
- A session also holds entries of type `code_documents`: the paths and the
|
|
794
|
+
versions of the documents a run of code read or wrote. They let a later run
|
|
795
|
+
write over a document that code read or wrote before. Where you render
|
|
796
|
+
`Session#entries` or `Session#transcript` for a person, skip them, as you
|
|
797
|
+
skip `code_call`.
|
|
798
|
+
- `before_tool` is asked about every call from code, by the name of the tool:
|
|
799
|
+
`read_file`, `write_file`, `list_files` and `delete_file` for the four file
|
|
800
|
+
operations, with what the code passed. The code receives what `after_tool`
|
|
801
|
+
returns, and for `files.read` the hook is given the document.
|
|
802
|
+
- `files` in code works through the built-in document tools. Where a document
|
|
803
|
+
tool is your own, code calls it as a tool, under its contract and its
|
|
804
|
+
approval rule.
|
|
805
|
+
- Code computes inside the host's process and holds Ruby's interpreter lock
|
|
806
|
+
while it does. The lock is passed on in the code's own loops, and not during
|
|
807
|
+
one built-in call such as a search in a long string, so other threads can
|
|
808
|
+
wait for as long as `timeout:`. Keep it short on a process that serves
|
|
809
|
+
requests. `timeout:` bounds the code's own computing and `total_timeout:`
|
|
810
|
+
the whole run with its calls.
|
|
811
|
+
- The result of `run_code` keeps 10,000 bytes, and the tool's description
|
|
812
|
+
states it.
|
|
813
|
+
- A child takes `sandbox:` as an agent option, on a `Runtime` too. Its code
|
|
814
|
+
reaches only the tools and the documents the child was granted.
|
|
815
|
+
|
|
816
|
+
### Skills
|
|
817
|
+
|
|
818
|
+
- `read_skill` now marks an unknown skill name as a failed tool result.
|
|
819
|
+
- Gemini also receives a loaded skill in its system instruction. You do not
|
|
820
|
+
need to change anything.
|
|
821
|
+
|
|
12
822
|
## From 0.5.x to 0.6.x
|
|
13
823
|
|
|
14
824
|
This is a safety-focused minor upgrade. The built-in Anthropic, OpenAI, and
|