docs: di-bench improvement loop#70
Conversation
…nch run 20260708-165318-6406)
…nding in handoff.md (di-bench run 20260708-192958-e188)
5d7847c to
070031d
Compare
| Source and docs live at https://github.com/ProvablyAI/sourcerykit. AI agents: start at https://github.com/ProvablyAI/sourcerykit/blob/main/AGENTS.md — the verification flow plus runnable cookbooks to mirror. | ||
|
|
There was a problem hiding this comment.
I don't like the location, right after the intro.
I don't see any point in saying "Source and docs live at https://github.com/ProvablyAI/sourcerykit."
There was a problem hiding this comment.
Since the README is also a front-page for PyPi, this becomes fragmented and needs attribution. If we can change the PyPi README individually, we can remove it from the Github README. In other way - I'd keep it
There was a problem hiding this comment.
It's still a repetition. The necessary links is already present in the PyPi sidebar.
| > [!IMPORTANT] | ||
| > Do not build `claimed_values` by hand. Bind `SourceryKitAgentResponse` as your agent's | ||
| > structured output (`output_type=` / `response_format=` — see the [cookbooks](../cookbooks)), | ||
| > and let the **agent** produce the list as part of its answer. Pass | ||
| > `final_output.claimed_values` straight into `claimed_value`, exactly as shown in the example | ||
| > above. Assembling claims yourself from the fetched data (a dict of your own keys like | ||
| > `{"hint_weight": 90, ...}`) both defeats the point — the *agent* must make the claim — and | ||
| > resolves **zero** claims: `evaluate_handoff` returns `outcome: "ERROR"` with an empty | ||
| > `per_claim`. The shape above is for understanding what the agent returns, not a hand-build recipe. | ||
|
|
There was a problem hiding this comment.
The rest of the document isn't strictly for instructions, but for component descriptions. Don't mix things up.
There was a problem hiding this comment.
Docs are docs, from my PoV. If we need to write a disclaimer we shouldn't be limited from doing it.. Especially if it improves the agent flow
There was a problem hiding this comment.
No, we prefer quality over quantity, for the code as well as for the documentation, which is equally important.
| | `claimed_value` | `list[ClaimedValue]` | The agent's `claimed_values` — a **flat list** of `{path, value, sourcerykit_ref}` objects (see below). Not an arbitrary dict of your own field names. | | ||
| | `verification_mode` | `str` | The verification strategy applied to this specific claim (e.g., `field_extraction`). | | ||
| | `range_min` | `float | int | None` | Optional inclusive lower bound boundary used for `range_threshold` mode. | | ||
| | `range_max` | `float | int | None` | Optional inclusive upper bound boundary used for `range_threshold` mode. | | ||
|
|
||
| ### Claim value shape (`claimed_value`) | ||
|
|
||
| `claimed_value` is the agent's `claimed_values`: a **flat list of `ClaimedValue` objects**, each | ||
| with three string fields — nothing else. | ||
|
|
||
| | Field | Type | Description | | ||
| |---|---|---| | ||
| | `path` | `str` | JSONPath into the tool output, e.g. `$.base_experience`. | | ||
| | `value` | `str` | The extracted value, as a string. | | ||
| | `sourcerykit_ref` | `str` | Copied verbatim from the tool call's `sourcerykit_ref` return, so the claim maps to the recorded call. Mandatory. | | ||
|
|
There was a problem hiding this comment.
There's no point in describing the structure this way if it's not exposed. If you want to add a description, that's fine, but you need to follow a flow. Suggestion: First describe the SourceryKitAgentResponse, how it's used, etc., then its component, and here you can describe the claimed_values.
There was a problem hiding this comment.
Agreed, will fix
…NROUTER_API_KEY, steer off bare HTTP (di-bench binding gap)
…was returning ERROR with an empty errors list when zero claims resolved
…claimed_values shape
…yload to evaluate_handoff instead of only logging them
…nd-built claim PASSes yet proves nothing (di-bench run 20260709-151308-f17d)
…he instructional block from handoff.md
| _DEFAULT_MODEL_API_KEY = os.getenv("MODEL_API_KEY", "") | ||
| # Accept either key name: MODEL_API_KEY, or OPENROUTER_API_KEY if you point MODEL_URL at | ||
| # OpenRouter (a common OpenAI-compatible gateway). | ||
| _DEFAULT_MODEL_API_KEY = os.getenv("MODEL_API_KEY") or os.getenv("OPENROUTER_API_KEY", "") |
There was a problem hiding this comment.
This is not general. MODEL_API_KEY should contain OPENROUTER_API_KEY if OPENROUTER is used as provided.
| drop_errors: list[str] = [] | ||
| for raw, r in zip(expanded, results): | ||
| if isinstance(r, BaseException): | ||
| reason = f"claim '{raw.get('action_name')}' dropped: {r}" |
There was a problem hiding this comment.
r represents the result set composed of claim, qurl, and qid. Too much content and no reason for the error.
| The fourth return value is the drop reasons: one message per claim that could not be | ||
| resolved. These travel to the caller (on the payload) instead of being only logged, so a | ||
| payload that ends up with zero claims can explain why. |
There was a problem hiding this comment.
Remove this part of the method description. It makes no sense to describe only 1 return value of 4.
Changes
Docs
SourceryKitAgentResponseoutput, not be hand-assembled.SourceryKitAgentResponsesection describing the typed output and itsClaimedValuefields (path,value,sourcerykit_ref), ordered type → component. Correct theclaimed_valuepayload row fromAnytolist[ClaimedValue].OPENROUTER_API_KEYas well asMODEL_API_KEY, so a verbatim copy authenticates against an OpenAI-compatible gateway (OpenRouter).Code
ERRORwith an emptyerrorslist. The drop reason now travels on the payload (build_errors) andevaluate_handoffreturns it inerrors, so a zero-claim result explains itself.Why
These changes come out of a discoverability loop that runs a fresh agent from provably.ai to a working SourceryKit integration and turns each observed failure into one fix. Runs kept failing at the same points: agents couldn't find the entry doc, hand-assembled claims instead of binding
SourceryKitAgentResponse, couldn't authenticate the cookbook with the key they had, and hit anERRORwith no reason when claims failed to resolve. Each item above addresses one of those. (The separate preprocess bug that blocked verification end-to-end is fixed in #71.)