neurouter 0.2.1 → 0.3.1

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.
package/README.md CHANGED
@@ -51,6 +51,54 @@ mean of that over the multi-step attempts. Cached input (OpenAI `cached_tokens`,
51
51
  writes are counted as input. `--transcripts <file>` writes every attempt untrimmed (`--transcript-max-chars`
52
52
  to cap each item).
53
53
 
54
+ Checks are outcome-based (0.2.2): expected values are computed at run time by running each task's reference
55
+ calls on the same mock data, only the arguments the prompt asks for are checked, answers are compared by
56
+ meaning (booleans, numbers, minor units, dates, ids), and call budgets are soft (over budget is reported as
57
+ efficiency, not failure). A suite is accepted only when every task's reference solution passes its own
58
+ checks (calibration; `--calibrate-with <model>` adds a model pass that flags disagreements for review).
59
+ `--max-run-tokens` caps a run's spend. Details, score definitions and the 0.2.1 suite converter
60
+ (`--migrate-suite`) and offline re-grade (`--regrade`): [packages/evals/README.md](packages/evals/README.md).
61
+
62
+ ## Agent contract
63
+
64
+ Tool results follow one of two contracts, chosen per session:
65
+
66
+ - **Contract 2** (default for servers created from this release on): every `tools/call` result is one envelope,
67
+ `{"ok","data","page","truncated","error","state"}` (plus an optional `hint`), as the only text item and as
68
+ `structuredContent`. `data` is the API's payload unchanged; `page` says `count`/`total`/`has_more` on list tools,
69
+ with `next_cursor`: pass it as `cursor` to the same tool with the same other arguments for the next page, whatever
70
+ the upstream's paging style (cursor tokens, page/per_page, offset/limit, `starting_after`, `Link` headers) and
71
+ for the rest of a list Neurouter cut. Cursors are signed, bound to the tool, the query arguments (not `fields`) and
72
+ the credential, and last 1 hour; a cursor sent with other arguments answers with the call that continues it. Every tool takes `fields` (dot paths, per item on lists; the overlay `include` is the default set) and
73
+ list tools take `limit` (the upstream page size); names the upstream already uses get an `nr_` prefix.
74
+ `truncated` names the object fields Neurouter clipped and the `fields` call that returns them; `error` has a code, a short message,
75
+ every invalid field with its allowed values, `retry` and `next` (the exact call to make next); `state` carries the
76
+ environment, write mode, task and call counter (and identical-result streaks). Unknown tools answer with an
77
+ envelope (`unknown_tool` + closest names), not a JSON-RPC error. In `run_script`, tool functions return plain data;
78
+ `ns.list_x.page(…)` returns a `Result` (`.data`, `.items`, `.page`, `.next()`, `.pages()`) and `ns.list_x.pages(…,
79
+ max_items=500)` the items of every page (`ops.pages(fn="ns.list_x", …)` is a deprecated alias). Tool errors raise
80
+ typed exceptions: `NotFound` (a `LookupError`), `InvalidArgs` (`ValueError`), `Forbidden`, `WritesDisabled` and
81
+ `ConfirmationRequired` (`PermissionError`), `Timeout` (`TimeoutError`), `RateLimited` and `UpstreamError`
82
+ (`RuntimeError`); catch them by name, by base or as `ToolError`. `str(e)` is short (code, message, next call) and
83
+ `ops.error(e)` returns the structured error (`code`, `message`, `retry`, `next`, `fields`, `plan`). `print()` output
84
+ comes back as `logs` (up to 2,000 characters); a return value over 8,192 characters (`limits.code.resultChars`) is
85
+ cut with `truncated` (`truncated.next` reads the rest) and a hint to return less.
86
+ There is no task framing: Neurouter infers tasks per credential, client and MCP session (10-minute idle gap),
87
+ counts `state.call`/`streak` in the task row (the same on every instance), and shows `state.left` when a
88
+ rate limit is down to 20%. One ops tool is listed, `neurouter_report(kind: done|blocked|unmet_need|tool_problem|
89
+ decision, text)`; the v1 names still answer. Write tools take `dry_run: true` (the plan: target, effect,
90
+ `reversible`). Outside prod a destructive call first answers `confirmation_required` with the plan and the same
91
+ call carrying `confirm: "ct_…"` (5 minutes, single use, bound to the arguments and the credential); scripts with
92
+ destructive calls do the same per plan. In prod your user approves through elicitation; tokens are not accepted.
93
+ - **Contract 1**: the 0.2.x shapes. Servers created before contract 2 keep it until switched.
94
+
95
+ A client picks a version with the capability `experimental["dev.neurouter/contract"] = {"versions":[2,1]}` or the
96
+ header `X-Neurouter-Contract: 2`; otherwise `exposure.contract` (server, or per environment in `neurouter.yaml`)
97
+ decides. `NEUROUTER_NEW_SERVER_CONTRACT` (default `2`) sets the contract of new servers. `exposure.outputSchema`
98
+ is `envelope` (default: the shared envelope schema with an open `data`), `none`, or `typed` (the shaped upstream
99
+ schema as `data`, validated before sending; a tool whose response does not match is re-listed without it and
100
+ reported in the inbox).
101
+
54
102
  ## Development
55
103
 
56
104
  | Command | What |