-
Notifications
You must be signed in to change notification settings - Fork 1
docs: di-bench improvement loop #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
774339d
15a3b6e
070031d
03cd7ca
633224a
66dd7c1
c161bbe
6446637
0a25f21
24aecff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,12 +61,13 @@ async def build_handoff_payload( | |
| instr = instructions if instructions is not None else default_instructions() | ||
|
|
||
| # Run claim resolution and trusted-endpoint fetch concurrently | ||
| (claims, query_urls, query_ids), trusted_endpoint_registry = await asyncio.gather( | ||
| (claims, query_urls, query_ids, build_errors), trusted_endpoint_registry = await asyncio.gather( | ||
| _build_claims(trace_id, blob, intercept_agent_id), | ||
| list_all_trusted_endpoints(), | ||
| ) | ||
|
|
||
| _log.info("build_handoff_payload_completed", claim_count=len(claims)) | ||
| _log.info("build_handoff_payload_completed", claim_count=len(claims), | ||
| dropped=len(build_errors)) | ||
|
|
||
| return HandoffPayload( | ||
| provably_mcp_url=settings.provably_mcp, | ||
|
|
@@ -83,6 +84,7 @@ async def build_handoff_payload( | |
| query_urls=query_urls, | ||
| task=task, | ||
| reasoning=reasoning, | ||
| build_errors=build_errors, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -123,15 +125,20 @@ async def _build_claims( | |
| trace_id: uuid.UUID, | ||
| fetch_and_claim_json: Any, | ||
| intercept_agent_id: str, | ||
| ) -> tuple[list[HandoffClaim], list[str], list[uuid.UUID]]: | ||
| """Aggregates, resolves intercept IDs, and emits tracking metadata.""" | ||
| ) -> tuple[list[HandoffClaim], list[str], list[uuid.UUID], list[str]]: | ||
| """Aggregates, resolves intercept IDs, and emits tracking metadata. | ||
|
|
||
| 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. | ||
|
Comment on lines
+131
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| """ | ||
|
|
||
| if not isinstance(fetch_and_claim_json, dict): | ||
| return [], [], [] | ||
| return [], [], [], ["fetch_and_claim is not a dict; no claims could be read"] | ||
|
|
||
| raw_claims = fetch_and_claim_json.get("claims") | ||
| if not isinstance(raw_claims, list): | ||
| return [], [], [] | ||
| return [], [], [], ["fetch_and_claim['claims'] is missing or not a list"] | ||
|
|
||
| # Filter to valid claim dicts up-front | ||
| valid_raws = [raw for raw in raw_claims if isinstance(raw, dict) and str(raw.get("action_name") or "").strip()] | ||
|
|
@@ -150,19 +157,22 @@ async def _build_claims( | |
| claims = [] | ||
| urls = [] | ||
| ids = [] | ||
| drop_errors: list[str] = [] | ||
| for raw, r in zip(expanded, results): | ||
| if isinstance(r, BaseException): | ||
| reason = f"claim '{raw.get('action_name')}' dropped: {r}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| _log.warning( | ||
| "claim_resolution_failed", | ||
| action_name=raw.get("action_name"), | ||
| error=str(r), | ||
| ) | ||
| drop_errors.append(reason) | ||
| continue | ||
| claims.append(r[0]) | ||
| urls.append(r[1]) | ||
| ids.append(r[2]) | ||
|
|
||
| return claims, urls, ids | ||
| return claims, urls, ids, drop_errors | ||
|
|
||
|
|
||
| async def _resolve_claim( | ||
|
|
||
There was a problem hiding this comment.
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.