Skip to content

fix: complete PR 765 review remediations - #810

Closed
seonghobae wants to merge 6 commits into
ContextualWisdomLab:fix/auto-reasoning-effort-contract-rebasedfrom
seonghobae:pr765-review-fixes-20260821
Closed

fix: complete PR 765 review remediations#810
seonghobae wants to merge 6 commits into
ContextualWisdomLab:fix/auto-reasoning-effort-contract-rebasedfrom
seonghobae:pr765-review-fixes-20260821

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Customer outcome

The gateway now recovers from the reported Azure/LiteLLM default-only temperature rejection by retrying the same provider request once without the unsupported optional field, while preserving the original provider diagnostic and all normal fallback behavior.

Review remediation

  • refresh the default embedding backend when the live agent registry changes;
  • validate Responses routing hints at the HTTP boundary;
  • enforce cumulative output-token budgets between every provider call and across state-store restarts;
  • reject unreachable host.docker.internal local-provider configuration at construction while retaining DNS loopback validation;
  • preserve partial diagnostics when an HTTP error body raises IncompleteRead;
  • retain synchronized sampling overrides without shared ModelClient mutation.

Protected delivery

The organization ruleset began protecting every branch while this exact head was under validation, so direct update of PR #765s head was correctly rejected. This stacked fork PR is the normal non-bypass path into that protected branch.

Verification

  • exact head: 513a815
  • focused review and provider boundary suite: 153 passed
  • full suite: 1645 passed in 553.26 seconds
  • git diff --check passed

Related parent: #765. Review and merge this stacked PR first; #765 then receives the fixes through its protected base branch.


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dcd9a5b6-ec80-4592-8a65-ebbd81a3b76d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Runtime aggregate verification on exact source head 513a815 reproduced the configured provider-neutral gateway boundary without retaining credentials or response bodies: gpt-5.6-sol with temperature 0.2 returned HTTP 400, and the identical request with temperature omitted returned HTTP 200. This is the exact transition implemented by the bounded one-time capability negotiation and covered by the Azure diagnostic regression.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

Devin Review found 4 potential issues.

Open in Devin Review

Comment on lines +3292 to +3300
raw, _served_id, _usage = self._invoke(
planner,
[
{"role": "system", "content": system},
{"role": "user", "content": task},
],
text=task,
role="thinker",
)

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.

📝 Info: BudgetExceededError caught by broad handler in generated planning

_plan_generated now calls _invoke, which can raise BudgetExceededError. conduct wraps planning in except Exception (orchestrator.py), so the hard-stop error is caught and it falls back to the template plan. Currently harmless: the first template step's _invoke re-checks the budget and raises before any provider call. Worth a narrow except BudgetExceededError: raise to keep the stop unambiguous.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Accepted. Local follow-up 7929f70 adds an explicit BudgetExceededError re-raise before the template fallback and a regression test. Focused verification passed 67 tests. The remote branch remains at 513a815 because the normal push was rejected by the active required-workflow ruleset; no bypass was used.

Comment on lines +2204 to +2212
restored = self.spend_analytics()["totals"]
self._budget_spent_output_tokens = max(
self._budget_spent_output_tokens,
restored["estimated_output_tokens"],
)
self._budget_spent_cost_usd = max(
self._budget_spent_cost_usd,
restored["estimated_cost_usd"] or 0.0,
)

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.

📝 Info: Budget ledger and run analytics intentionally diverge

spend_analytics reports budget.spent_output_tokens from the in-flight ledger, while totals.estimated_output_tokens still comes from persisted runs. They now diverge because the ledger counts planner, judge, and failover calls absent from any trace. Restart restore uses max(meter, run-estimate), which de-duplicates rather than sums, so no double counting; but when the char estimate exceeds reported tokens it over-states spend and can block sooner.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Reviewed against ADR 0014. The budget ledger intentionally includes in-flight provider calls that may not yet have persisted workflow rows; restart reconciliation uses the durable meter and avoids double counting. No source change is justified by this informational finding.

Comment on lines +2450 to 2460
with self._budget_spend_lock:
recorded_output_tokens = self._budget_spent_output_tokens - budget_before[0]
recorded_cost_usd = self._budget_spent_cost_usd - budget_before[1]
self._budget_spent_output_tokens += max(
0,
workflow_output_tokens - recorded_output_tokens,
)
self._budget_spent_cost_usd += max(
0.0,
workflow_cost_usd - recorded_cost_usd,
)

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.

📝 Info: Judge counted exactly once by reconciliation

The reconciliation adds max(0, workflow_output_tokens - recorded_output_tokens). When the judge records in-flight via the adapter, recorded >= workflow and it adds 0; when the judge bypasses in-flight recording, the reconciliation supplies judge_usage. Either way the judge is counted once, so this is a necessary safety net, not dead code.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Reviewed against ADR 0014. The reconciliation is the required safety net for judge usage when adapter metering is absent, while preventing duplicate counting when it is present. No source change is needed.

Comment on lines +319 to +320
if scheme == "local" and not _is_local_provider_url(self.base_url):
raise ValueError("local:// gateway URLs require a well-formed explicit loopback endpoint")

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.

🔍 Existing host.docker.internal agents break on load

Removing host.docker.internal from LOCAL_PROVIDER_HOSTS plus the new __post_init__ check makes any local://host.docker.internal agent raise ValueError at construction. from_dict shares this path, so a stored agent-pool row or agents JSON using that host raises during load_all/load_agents on startup. Intended hardening, but a breaking migration for Docker-gateway configs.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Reviewed against ADR 0012 and the ADR 0004 decision recorded on 2026-08-21. local:// is intentionally authenticated and loopback-only; host.docker.internal is not a loopback guarantee and must remain rejected. The DNS resolution and rebinding check remains in the provider validator. No compatibility reintroduction is appropriate.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Maintainer audit — exact-head follow-up\n\n- Repository: ContextualWisdomLab/contextual-orchestrator\n- Pull request: #810\n- Remote exact head: \n- Base: ()\n- Remote state: OPEN, non-Draft, MERGEABLE, BLOCKED; formal approvals: 0.\n- Current hosted checks: 17 runs; 8 skipped/completed and 9 queued, including Close Empty, Strix, Dependency Review, Scorecard, Trivy FS, required-workflow bootstrap, OSV, scheduler sweep, and Semgrep. Queued runs are not success evidence.\n- Devin finding on generated planning: accepted. Local exact follow-up commit adds a narrow re-raise before template fallback and a regression test; focused verification: ................................................................... [100%]

67 passed in 0.85s -> 67 passed.\n- Devin findings on budget/run analytics and judge reconciliation: reviewed against ADR 0014; no source change, retained as intentional ledger reconciliation behavior.\n- Devin finding on : reviewed against ADR 0012 and the 2026-08-21 ADR 0004 decision. The loopback-only contract and DNS rebinding check are intentional; no compatibility reintroduction is appropriate.\n- Normal push of the local follow-up was attempted against the unchanged remote head and rejected by the active ruleset because required workflows are not satisfied. No bypass, direct protected push, force push, fake status, or self-approval was used.\n- Decision: WAIT_AND_REMEDIATE. No merge or guarded force merge.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Correction to the preceding maintainer audit: shell quoting stripped inline code markers from that comment. The authoritative details are: remote exact head 513a815; base 5379157; PR open, non-Draft, mergeable, blocked, with zero formal approvals. Hosted checks are 17 total, 8 skipped/completed and 9 queued. Local follow-up 7929f70 adds the narrow BudgetExceededError re-raise and regression test; focused verification passed 67 tests. The normal push was rejected by the active required-workflow ruleset. ADR 0012 and ADR 0004 support keeping host.docker.internal rejected. Decision remains WAIT_AND_REMEDIATE; no bypass or merge was used.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Follow-up to the #810 maintainer audit: local commit 7929f70 was verified after the focused run with the full suite: 1646 passed in 552.26 seconds. Compileall, actionlint, git diff check, and Semgrep completed cleanly; pip-audit against requirements.lock reported no known vulnerabilities. These are local exact follow-up results only because the normal push remains rejected and the remote exact head is still 513a815. Hosted checks and formal approval remain outstanding. Decision remains WAIT_AND_REMEDIATE.

@seonghobae

Copy link
Copy Markdown
Contributor Author

At current parent head 513a8157e667a6adbe7b91b5e802887a55fe9cd8, generated planning catches broad exceptions and could treat BudgetExceededError as an invalid plan. Stacked PR #813 (6e5e1932) re-raises the budget error before template fallback and adds a regression proving _plan is not called.

Validation: 15 passed for generated workflow and budget enforcement tests, compileall passed, changed-test lint passed, and diff check passed. Existing unrelated F841 in the embedding retry path was not changed. No force push or protection bypass was used.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded by merged #813. Exact tree comparison shows #813 merge d0a3a32a0fc75a7818f89141544c3727629db56e contains every change from this PR head 513a8157e667a6adbe7b91b5e802887a55fe9cd8; the only delta is the subsequent generated-planner budget-stop regression in #813. The current base 5b43ebfa contains that merge. Closing the now-duplicate PR without bypass, force push, or a second merge.

@seonghobae seonghobae closed this Aug 21, 2026
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.

1 participant