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/docs/reliability.md
CHANGED
|
@@ -20,13 +20,16 @@ result.errored?
|
|
|
20
20
|
result.handed_off?
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
`result.text` reads the final assistant message
|
|
23
|
+
`result.text` reads the final assistant message, or the text the model last
|
|
24
|
+
wrote where that message is empty. `result.output` is the parsed,
|
|
24
25
|
validated value from task mode. `result.usage` sums provider attempts and
|
|
25
26
|
compaction calls made during that invocation.
|
|
26
27
|
|
|
27
28
|
Failures the model can correct stay in band. Unknown tools, invalid arguments,
|
|
28
29
|
policy blocks, expected tool failures, handler exceptions, and timeouts become
|
|
29
|
-
typed tool results.
|
|
30
|
+
typed tool results. A call that runs alone and fails holds back the calls after
|
|
31
|
+
it in that turn, see
|
|
32
|
+
[The order of a turn's calls](tool-contracts.md#the-order-of-a-turns-calls).
|
|
30
33
|
|
|
31
34
|
Built-in provider failures, including exhausted retries and provider response
|
|
32
35
|
limits, finish as `result.errored?`. Configuration and Session contract failures,
|
|
@@ -46,7 +49,9 @@ subscriber bugs into model output.
|
|
|
46
49
|
|
|
47
50
|
Only one Agent may actively call `run` or `resume` for a Session at a time. The
|
|
48
51
|
store can accept independent approval, steer, and worker-report appends, but
|
|
49
|
-
active runners are a host scheduling concern.
|
|
52
|
+
active runners are a host scheduling concern. With a lock adapter configured, a
|
|
53
|
+
second runner raises `Mistri::SessionBusyError` before it appends; see
|
|
54
|
+
[Sessions](sessions.md#concurrency-and-crashes).
|
|
50
55
|
|
|
51
56
|
Even with one runner, this gap remains:
|
|
52
57
|
|
|
@@ -62,15 +67,15 @@ Build write tools around a domain idempotency key or reconciliation handle:
|
|
|
62
67
|
|
|
63
68
|
```ruby
|
|
64
69
|
Mistri::Tool.define(
|
|
65
|
-
"
|
|
70
|
+
"place_order", "Places one order.",
|
|
66
71
|
schema: lambda {
|
|
67
72
|
string :order_id, "Host-issued idempotency key", required: true
|
|
68
|
-
string :
|
|
73
|
+
string :customer_id, "Customer ID", required: true
|
|
69
74
|
},
|
|
70
75
|
) do |args|
|
|
71
|
-
|
|
76
|
+
Orders.create_once!(
|
|
72
77
|
idempotency_key: args.fetch("order_id"),
|
|
73
|
-
|
|
78
|
+
customer_id: args.fetch("customer_id"),
|
|
74
79
|
)
|
|
75
80
|
end
|
|
76
81
|
```
|
|
@@ -97,7 +102,7 @@ policy = Mistri::RetryPolicy.new(
|
|
|
97
102
|
max_delay: 30.0,
|
|
98
103
|
)
|
|
99
104
|
|
|
100
|
-
agent = Mistri.agent("claude-opus-
|
|
105
|
+
agent = Mistri.agent("claude-opus-5-5", retries: policy)
|
|
101
106
|
```
|
|
102
107
|
|
|
103
108
|
Set `retries: false` to disable the Agent retry loop.
|
|
@@ -107,6 +112,13 @@ streams, and empty completions are retryable. Authentication errors, invalid
|
|
|
107
112
|
requests, content-policy refusals, unsafe configuration, and host bugs fail
|
|
108
113
|
fast. A provider `Retry-After` value is honored within `max_delay`.
|
|
109
114
|
|
|
115
|
+
An empty completion is retried only while the model has written no text since
|
|
116
|
+
the user's last message. Once it has, an empty completion ends the turn. A
|
|
117
|
+
model that answers and then calls a tool often adds nothing to the tool's
|
|
118
|
+
result, and the same request gives the same empty answer. The final message of
|
|
119
|
+
such a run is empty, so `result.text` reads what the model wrote before the
|
|
120
|
+
tool call, which `result.said` holds.
|
|
121
|
+
|
|
110
122
|
Each retry sends unchanged durable history. Failed attempts are not appended as
|
|
111
123
|
conversation messages, but their usage and retry record remain available for
|
|
112
124
|
accounting.
|
|
@@ -115,6 +127,12 @@ The subscriber receives `:retry` with `attempt`, `max_attempts`, and `delay`.
|
|
|
115
127
|
Only the accepted provider attempt's `:done` or `:error` event is released, so a
|
|
116
128
|
recovered retry does not flash a terminal failure and then retract it.
|
|
117
129
|
|
|
130
|
+
A request that a provider refuses as longer than the model's context window is
|
|
131
|
+
not retried as it is. Its error has the type `ContextTooLongError`, and an
|
|
132
|
+
agent with compaction compacts once and sends the turn again. See
|
|
133
|
+
[Compaction](sessions.md#compaction). A custom provider reports the same type
|
|
134
|
+
in the error of its errored message to get the same recovery.
|
|
135
|
+
|
|
118
136
|
MCP `tools/call` is intentionally different. Once sent, a missing response is
|
|
119
137
|
an ambiguous side effect and is not replayed by the Client. The Agent bridge
|
|
120
138
|
returns that exception as an error-marked tool result. See
|
|
@@ -147,9 +165,13 @@ Loop-level events are:
|
|
|
147
165
|
- `:tool_started` when a resolved call commits to handler invocation;
|
|
148
166
|
- `:tool_result` after settlement, with a required `tool_error` boolean;
|
|
149
167
|
- `:approval_needed` when a prepared call parks;
|
|
150
|
-
- `:compacting` before summary work
|
|
151
|
-
summary in `content
|
|
168
|
+
- `:compacting` before summary work, then `:compaction` with the committed
|
|
169
|
+
summary in `content` and the summarizing reply in `message`, or
|
|
170
|
+
`:compaction_failed` with the reason in `error_message`;
|
|
152
171
|
- `:retry` before provider backoff;
|
|
172
|
+
- `:thinking_dropped` when the provider discarded earlier thinking it could
|
|
173
|
+
no longer verify: after `:start` on Anthropic, with the finished response on
|
|
174
|
+
OpenAI;
|
|
153
175
|
- `:subagent_report` when a running background child reaches a terminal state;
|
|
154
176
|
an inactive `Child#stop` persists the report without this callback because it
|
|
155
177
|
has no event sink.
|
|
@@ -275,13 +297,13 @@ Anthropic and OpenAI require the tier explicitly:
|
|
|
275
297
|
|
|
276
298
|
```ruby
|
|
277
299
|
anthropic = Mistri.agent(
|
|
278
|
-
"claude-opus-
|
|
300
|
+
"claude-opus-5-5",
|
|
279
301
|
budget: Mistri::Budget.new(cost_usd: 5.00),
|
|
280
302
|
provider_options: { service_tier: "standard_only" },
|
|
281
303
|
)
|
|
282
304
|
|
|
283
305
|
openai = Mistri.agent(
|
|
284
|
-
"gpt-
|
|
306
|
+
"gpt-6.1-terra",
|
|
285
307
|
budget: Mistri::Budget.new(cost_usd: 5.00),
|
|
286
308
|
provider_options: { service_tier: "default" },
|
|
287
309
|
)
|
|
@@ -317,7 +339,15 @@ before their body is read. Error responses retain at most a 500-byte valid UTF-8
|
|
|
317
339
|
preview. Requests use identity encoding so compressed expansion cannot evade
|
|
318
340
|
the limit.
|
|
319
341
|
|
|
320
|
-
Completed SSE JSON records
|
|
342
|
+
Completed SSE JSON records are scanned before parsing: 64 levels and 64 KiB
|
|
343
|
+
per numeric token, for every provider and for an MCP server. A Gemini record
|
|
344
|
+
is also held to 20,001 JSON tokens, because a tool call's arguments arrive as
|
|
345
|
+
an object inside it. No other record is counted.
|
|
346
|
+
OpenAI and Anthropic records are not counted: the arguments of a tool the host
|
|
347
|
+
runs arrive there as an encoded string with its own limits, and the OpenAI
|
|
348
|
+
stream repeats the request's tool definitions in its own events, which a large
|
|
349
|
+
tool list takes past any fixed count.
|
|
350
|
+
|
|
321
351
|
Fragmented Anthropic and OpenAI tool arguments also carry an aggregate 8 MiB
|
|
322
352
|
limit across deltas; their partial preview refreshes on a bounded schedule while
|
|
323
353
|
raw delta events continue.
|
|
@@ -332,8 +362,8 @@ agent = Mistri.agent(
|
|
|
332
362
|
)
|
|
333
363
|
```
|
|
334
364
|
|
|
335
|
-
The byte boundary is configurable.
|
|
336
|
-
|
|
365
|
+
The byte boundary is configurable. The depth and number ceilings, and the token
|
|
366
|
+
ceiling where it applies, are fixed and are not raised by that option.
|
|
337
367
|
|
|
338
368
|
## Provider input and options
|
|
339
369
|
|
|
@@ -356,19 +386,140 @@ Provider constructor settings go through `provider_options:`:
|
|
|
356
386
|
|
|
357
387
|
```ruby
|
|
358
388
|
Mistri.agent(
|
|
359
|
-
"gpt-
|
|
389
|
+
"gpt-6.1-sol",
|
|
360
390
|
provider_options: { reasoning: { summary: "auto" } },
|
|
361
391
|
)
|
|
362
392
|
|
|
363
393
|
Mistri.agent(
|
|
364
|
-
"claude-opus-
|
|
394
|
+
"claude-opus-5-5",
|
|
365
395
|
provider_options: { cache: false },
|
|
366
396
|
)
|
|
367
397
|
```
|
|
368
398
|
|
|
369
399
|
Provider-specific per-turn overrides belong on a directly constructed
|
|
370
400
|
provider's `stream` contract. The Agent intentionally exposes a stable common
|
|
371
|
-
loop rather than mirroring every provider option as a top-level keyword.
|
|
401
|
+
loop rather than mirroring every provider option as a top-level keyword. One
|
|
402
|
+
override is common to every built-in provider: `max_tokens:` bounds that
|
|
403
|
+
request's output (OpenAI `max_output_tokens`, Gemini `maxOutputTokens`); the
|
|
404
|
+
compactor uses it for its summary request.
|
|
405
|
+
|
|
406
|
+
### GPT-6.2
|
|
407
|
+
|
|
408
|
+
Select `gpt-6.2-sol` or `gpt-6.2-astra` explicitly. `gpt-6.1-sol` stays the
|
|
409
|
+
default OpenAI model. Both reject the reasoning effort `none`.
|
|
410
|
+
|
|
411
|
+
[GPT-6.2](https://developers.openai.com/api/docs/guides/latest-model/gpt-6.2-astra)
|
|
412
|
+
appends top-level `instructions` after the input and never caches them. On
|
|
413
|
+
OpenAI's own origin Mistri therefore sends the system prompt as a developer
|
|
414
|
+
message at the start of the input, for every model. Earlier models cache both
|
|
415
|
+
forms as one prefix. Another `origin:` still receives `instructions`, so
|
|
416
|
+
through a gateway GPT-6.2 does not cache the system prompt.
|
|
417
|
+
|
|
418
|
+
GPT-6.2 also removes replayed reasoning when the history before it has
|
|
419
|
+
changed, and still answers 200. The stream then emits `:thinking_dropped` with
|
|
420
|
+
the reason in `event.content`, such as `prefix_mismatch`, and the run log
|
|
421
|
+
prints a warning. What keeps a Claude prefix stable keeps this one stable too;
|
|
422
|
+
see [Thinking is signed against the prefix](#thinking-is-signed-against-the-prefix).
|
|
423
|
+
|
|
424
|
+
### Gemini 4
|
|
425
|
+
|
|
426
|
+
Select `gemini-4-carbon`, `gemini-4-argon`, `gemini-4-neon`, or
|
|
427
|
+
`gemini-4-hydrogen` explicitly. `gemini-3.8-flash` stays the default Gemini
|
|
428
|
+
model.
|
|
429
|
+
|
|
430
|
+
Input, thinking, and output
|
|
431
|
+
[share one window](https://aistudio.google.com/docs/whats-new-gemini-4-argon)
|
|
432
|
+
of 1,048,576 tokens. Automatic compaction therefore starts at 978,944 tokens
|
|
433
|
+
on these models, earlier than on Gemini 3.
|
|
434
|
+
|
|
435
|
+
One request returns at most 65,536 tokens of thinking and output together,
|
|
436
|
+
and that is what a turn gets by default. To let an answer go on, pass
|
|
437
|
+
`max_tokens:`:
|
|
438
|
+
|
|
439
|
+
```ruby
|
|
440
|
+
Mistri.agent(
|
|
441
|
+
"gemini-4-argon",
|
|
442
|
+
provider_options: { max_tokens: 262_144 },
|
|
443
|
+
compaction: Mistri::Compaction.new(reserve: 262_144 + 4_096),
|
|
444
|
+
)
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
When the API says the answer continues, Mistri sends the same request again
|
|
448
|
+
with the API's token and goes on in the same message, up to 32 requests. Each
|
|
449
|
+
request is billed, so the usage counts all of them. The message's
|
|
450
|
+
`usage.context` is what sits in the context afterwards, and
|
|
451
|
+
`agent.context_usage` reads it. The output shares the window, so a host that
|
|
452
|
+
raises `max_tokens:` raises the compaction `reserve:` with it.
|
|
453
|
+
|
|
454
|
+
A continued answer can hold more than one text block. They join with nothing
|
|
455
|
+
between them, as `message.text` does. A request that fails inside a continued
|
|
456
|
+
answer fails the turn. A retry then sends the answer again from its first
|
|
457
|
+
request, so the requests before the failure are billed a second time. An
|
|
458
|
+
answer that reaches the 32 requests is not retried.
|
|
459
|
+
|
|
460
|
+
Mistri sends no thinking level, so the model's own applies: `medium` on Carbon
|
|
461
|
+
and Argon, `high` on Neon and Hydrogen. Pass one through `thinking:`, with
|
|
462
|
+
`includeThoughts: true` beside it to keep the summaries. `minimal` is refused,
|
|
463
|
+
and only Neon and Hydrogen take `xhigh`.
|
|
464
|
+
|
|
465
|
+
With thought summaries on, which is the default, the model writes while it
|
|
466
|
+
thinks. With them off it sends nothing until it has finished thinking, which
|
|
467
|
+
can take longer than the 300 seconds of `read_timeout:`. A host that turns
|
|
468
|
+
them off raises `read_timeout:`; Google asks for 20 minutes.
|
|
469
|
+
|
|
470
|
+
Google answers a request for `gemini-3.5-flash` with `gemini-3.6-flash`. The
|
|
471
|
+
catalog holds the newer id, and the older one resolves to it.
|
|
472
|
+
|
|
473
|
+
### GPT-6 Astra and Fable 5.1
|
|
474
|
+
|
|
475
|
+
Select `gpt-6-astra` or `claude-fable-5-1` explicitly; adding them to the catalog
|
|
476
|
+
does not change any default model. Both support streaming tools, native
|
|
477
|
+
structured output, context-window accounting, and standard-tier cost estimates.
|
|
478
|
+
|
|
479
|
+
[Astra](https://developers.openai.com/api/docs/models/gpt-6-astra) accepts
|
|
480
|
+
reasoning effort `low`, `medium`, `high`, `xhigh`, or `max`, not `none` or
|
|
481
|
+
`minimal`. Its standard rates increase above 272,000 input tokens, including
|
|
482
|
+
cached tokens; Mistri applies that tier to each request.
|
|
483
|
+
|
|
484
|
+
[Fable 5.1](https://platform.claude.com/docs/en/models/fable-5-1/migration-guide)
|
|
485
|
+
uses always-on adaptive thinking. Keep Mistri's default thinking configuration;
|
|
486
|
+
disabled or token-budget thinking and forced `tool_choice: any/tool` are not
|
|
487
|
+
supported. It also requires an eligible Anthropic account with 30-day retention.
|
|
488
|
+
|
|
489
|
+
### Claude 5.5 models and Fable 5.2
|
|
490
|
+
|
|
491
|
+
`claude-opus-5-5` is the default Anthropic model. Select `claude-sonnet-5-5`,
|
|
492
|
+
`claude-haiku-5-5`, or `claude-fable-5-2` explicitly. Opus 5.5, Sonnet 5.5, and
|
|
493
|
+
Fable 5.2 reject disabled thinking and forced `tool_choice: any/tool`; Haiku
|
|
494
|
+
5.5 rejects token-budget thinking. Keep Mistri's default thinking
|
|
495
|
+
configuration.
|
|
496
|
+
|
|
497
|
+
### Thinking is signed against the prefix
|
|
498
|
+
|
|
499
|
+
Fable 5.1, Fable 5.2, and the Claude 5.5 models sign each thinking block
|
|
500
|
+
against the system prompt, the tool definitions, and every earlier message.
|
|
501
|
+
When one of those changes, the API can no longer verify the earlier thinking.
|
|
502
|
+
Accounts created since 31 August 2026 reject such a request, and Fable 5.2
|
|
503
|
+
rejects it on every account.
|
|
504
|
+
|
|
505
|
+
Mistri asks the API to drop thinking it cannot verify, so the request
|
|
506
|
+
succeeds. The model then reasons again, which costs output tokens. The stream
|
|
507
|
+
emits `:thinking_dropped` with the reason in `event.content`, and the run log
|
|
508
|
+
prints a warning.
|
|
509
|
+
|
|
510
|
+
To avoid that cost, keep the prefix stable for the life of a session:
|
|
511
|
+
|
|
512
|
+
- Build the system prompt once. Do not put the time, a counter, or other
|
|
513
|
+
per-request text in it.
|
|
514
|
+
- Do not reword a tool description or change the tool list.
|
|
515
|
+
- A context transform that changes between turns changes the prefix.
|
|
516
|
+
`Reminder.every` does so each time it fires.
|
|
517
|
+
|
|
518
|
+
Mistri drops pre-compaction thinking itself, because its own
|
|
519
|
+
[compaction boundary](sessions.md#compaction) changes the prefix. Mistri sends
|
|
520
|
+
the control only to `api.anthropic.com`. For another `origin:`, pass
|
|
521
|
+
`block_binding` in `thinking:`; see [Upgrading](../UPGRADING.md#unreleased).
|
|
522
|
+
Do not rewrite the stored transcript or tool-call/result pairs.
|
|
372
523
|
|
|
373
524
|
## Custom providers
|
|
374
525
|
|
|
@@ -390,8 +541,10 @@ end
|
|
|
390
541
|
Disable compaction explicitly only when a custom provider cannot describe a
|
|
391
542
|
model context window.
|
|
392
543
|
|
|
393
|
-
It returns an assistant `Mistri::Message
|
|
394
|
-
`Mistri::
|
|
544
|
+
It returns an assistant `Mistri::Message` with an explicit `stop_reason` from
|
|
545
|
+
`Mistri::StopReason`. In particular, compaction accepts only `:stop` with
|
|
546
|
+
nonblank text and no tool calls; missing completion metadata is not success.
|
|
547
|
+
A completed tool call must be a `Mistri::ToolCall` with:
|
|
395
548
|
|
|
396
549
|
- a non-empty UTF-8 String ID unique for new calls in the Session;
|
|
397
550
|
- a non-empty UTF-8 String name;
|
|
@@ -403,10 +556,26 @@ A malformed completed envelope rejects the whole provider attempt before the
|
|
|
403
556
|
assistant message persists or any sibling tool runs. Do not invent missing IDs
|
|
404
557
|
inside the Agent; the provider owns its wire correlation.
|
|
405
558
|
|
|
559
|
+
A reminder Mistri wrote for the model arrives in `messages` as a user
|
|
560
|
+
message, unless the provider answers `system_messages?` with true; see
|
|
561
|
+
[Tools on demand](tool-contracts.md#tools-on-demand).
|
|
562
|
+
|
|
406
563
|
Custom providers may return `native_output_schema(schema)` when they can enforce
|
|
407
564
|
the requested task contract. Returning nil leaves the prompt and local
|
|
408
565
|
validation path intact.
|
|
409
566
|
|
|
567
|
+
A custom provider may answer `count_tokens(messages:, system:, tools:, **)`
|
|
568
|
+
with its own count of the input tokens of the request that `stream` would
|
|
569
|
+
send for the same arguments, or with nil. Mistri then reads the context level
|
|
570
|
+
from it where an estimate could not decide. Without it the estimate stands.
|
|
571
|
+
|
|
572
|
+
A custom provider that writes a compaction itself answers `compacts?` with
|
|
573
|
+
true, takes `compaction: { instructions: }` among the options of `stream`,
|
|
574
|
+
and replies with one `Mistri::Content::Compaction`. One whose API removes the
|
|
575
|
+
reasoning of a turn that follows a summary the caller wrote answers
|
|
576
|
+
`summary_after_kept?` with true, and Mistri then places its own summary
|
|
577
|
+
after the turns it leaves.
|
|
578
|
+
|
|
410
579
|
To support cost budgets, return true from `prices_usage?` and attach a known
|
|
411
580
|
cost to every response, commonly with `Mistri::Usage#with_cost`. Missing or
|
|
412
581
|
partial pricing then fails closed at runtime.
|
|
@@ -424,23 +593,40 @@ $ bundle exec rake test
|
|
|
424
593
|
$ bundle exec rubocop
|
|
425
594
|
```
|
|
426
595
|
|
|
427
|
-
Gated live tests exercise exact provider regressions when keys are present
|
|
596
|
+
Gated live tests exercise exact provider regressions when keys are present.
|
|
597
|
+
The second task holds one cell of the compaction eval and the replay of thinking
|
|
598
|
+
on every model that binds it, which are most of a live run's cost:
|
|
428
599
|
|
|
429
600
|
```console
|
|
430
|
-
$
|
|
601
|
+
$ bundle exec rake live
|
|
602
|
+
$ bundle exec rake live:compaction
|
|
431
603
|
```
|
|
432
604
|
|
|
433
605
|
The integration harness runs critical end-to-end scenarios across an Anthropic,
|
|
434
|
-
OpenAI, and Gemini model by default:
|
|
606
|
+
OpenAI, and Gemini model by default, in one process for each model:
|
|
435
607
|
|
|
436
608
|
```console
|
|
437
609
|
$ bundle exec rake integration
|
|
438
|
-
$ MISTRI_INTEGRATION_MODELS=claude-opus-
|
|
610
|
+
$ MISTRI_INTEGRATION_MODELS=claude-opus-5-5 bundle exec rake integration
|
|
439
611
|
```
|
|
440
612
|
|
|
441
613
|
Keys load from the gitignored `.env.development.local`. A missing key skips that
|
|
442
614
|
provider; inspect the test output before claiming a full three-provider run.
|
|
443
615
|
|
|
616
|
+
The official MCP conformance suite runs against the MCP client, at the version
|
|
617
|
+
pinned in the Rakefile, for each revision of the specification. It needs Node
|
|
618
|
+
and no key. The scenarios that are expected to fail are listed with their
|
|
619
|
+
reasons in `script/conformance/expected_failures.yml`:
|
|
620
|
+
|
|
621
|
+
```console
|
|
622
|
+
$ bundle exec rake conformance
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
A run that called a vendor ends with a report of those calls: for each model
|
|
626
|
+
the calls, the seconds waited, the tokens and their cost at catalog prices,
|
|
627
|
+
then the slowest tests. The cost is an estimate from the usage each call
|
|
628
|
+
reported, not a bill.
|
|
629
|
+
|
|
444
630
|
## Related guides
|
|
445
631
|
|
|
446
632
|
- [Tool contracts](tool-contracts.md)
|