Skip to content

docs: di-bench improvement loop#70

Open
aural-psynapse wants to merge 10 commits into
mainfrom
docs/di-bench-loop
Open

docs: di-bench improvement loop#70
aural-psynapse wants to merge 10 commits into
mainfrom
docs/di-bench-loop

Conversation

@aural-psynapse

@aural-psynapse aural-psynapse commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Changes

Docs

  • AGENTS.md — note it is the canonical agent entry point (mirrored as the provably.ai machine view), and make explicit that claims must come from the agent's own SourceryKitAgentResponse output, not be hand-assembled.
  • docs/handoff.md — add a SourceryKitAgentResponse section describing the typed output and its ClaimedValue fields (path, value, sourcerykit_ref), ordered type → component. Correct the claimed_value payload row from Any to list[ClaimedValue].
  • cookbooks/openai_agents — accept OPENROUTER_API_KEY as well as MODEL_API_KEY, so a verbatim copy authenticates against an OpenAI-compatible gateway (OpenRouter).

Code

  • evaluate_handoff / build_handoff_payload — when a claim can't be resolved it was dropped with only a log line, so a payload that ended up with zero claims surfaced as ERROR with an empty errors list. The drop reason now travels on the payload (build_errors) and evaluate_handoff returns it in errors, 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 an ERROR with 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.)

Comment thread README.md Outdated
Comment on lines +17 to +18
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@SimoneBottoni SimoneBottoni Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still a repetition. The necessary links is already present in the PyPi sidebar.

@aural-psynapse aural-psynapse Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment thread docs/handoff.md Outdated
Comment on lines +100 to +109
> [!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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the document isn't strictly for instructions, but for component descriptions. Don't mix things up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we prefer quality over quantity, for the code as well as for the documentation, which is equally important.

@aural-psynapse aural-psynapse Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread docs/handoff.md Outdated
Comment on lines +84 to +99
| `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. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
…yload to evaluate_handoff instead of only logging them
…nd-built claim PASSes yet proves nothing (di-bench run 20260709-151308-f17d)
_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", "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r represents the result set composed of claim, qurl, and qid. Too much content and no reason for the error.

Comment on lines +131 to +133
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this part of the method description. It makes no sense to describe only 1 return value of 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants