Skip to content

fix: scope structured provider failures to request - #867

Merged
seonghobae merged 11 commits into
fix/provider-backed-embedding-batchfrom
fix/request-scoped-structured-readiness
Aug 26, 2026
Merged

fix: scope structured provider failures to request#867
seonghobae merged 11 commits into
fix/provider-backed-embedding-batchfrom
fix/request-scoped-structured-readiness

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • exclude a failed structured provider from every remaining stage in the same request
  • persist readiness/circuit failure evidence for provider-response and deadline failures
  • return the existing typed no_viable_agent retry contract when the declared set is exhausted

Verification

  • uv run pytest -q tests/test_provider_reliability.py tests/test_openai_passthrough.py tests/test_model_judge.py (75 passed)
  • uv run python -m compileall -q contextual_orchestrator

Stacked on the delivered provider-backed embedding owner branch so the combined runtime tree remains reproducible.


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Aug 26, 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: 9cd7dea1-2d1a-4229-9260-4531949edcd2

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.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae merged commit b49d6ff into fix/provider-backed-embedding-batch Aug 26, 2026
1 of 2 checks passed
@seonghobae
seonghobae deleted the fix/request-scoped-structured-readiness branch August 26, 2026 10:08

@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 2 new potential issues.

Open in Devin Review

Comment on lines +4414 to +4416
admitted = self._request_admitted_agents.get()
if admitted is not None:
candidates = [agent for agent in candidates if agent.id in admitted]

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.

🟡 Semantic-affinity embedding selection disabled during conduct

The request-admitted set, built only from structured chat readiness, is applied by _ranked_agents to the re-entrant embedding lookup reached via _embedding_agent_id. A dedicated embedding provider is excluded, so select_capability_agent("embedding") fails and semantic-affinity ranking silently falls back to declaration order for the whole conducted request.

Prompt for agents
The request-scoped admitted-agent filter added in _ranked_agents (contextual_orchestrator/orchestrator.py around lines 4414-4416) is intended to restrict chat provider selection during a conducted request to structured-chat-ready agents. However _ranked_agents is re-entrant: _semantic_affinities -> _embed_cached -> _embedding_agent_id -> select_capability_agent -> _capability_agents calls _ranked_agents again with capability="embedding", chat_only=False. Because the admitted set only contains structured-chat-ready (or mock) agents, a dedicated embedding provider is filtered out, making embedding selection fail and disabling semantic-affinity ranking for the whole conduct request. Consider scoping the admitted filter to chat-role ranking only (e.g. only apply it when chat_only is True, or when the capability/role is a chat role), so non-chat capability resolution like embeddings is not incorrectly gated by structured chat readiness.
Open in Devin Review

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

Comment on lines +4108 to +4121
admitted = self._structured_admitted_agent_ids()
if not admitted:
raise NoViableAgentError(
retry_after_seconds=max(1, math.ceil(self.circuit_reset_seconds))
)
token = self._request_failed_agents.set(set())
admitted_token = self._request_admitted_agents.set(admitted)
try:
return self._conduct_request(
messages, model_name=model_name, progress=progress
)
finally:
self._request_admitted_agents.reset(admitted_token)
self._request_failed_agents.reset(token)

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 conduct gate raises NoViableAgentError only when the entire admitted set is empty. For an explicit model_name, _plan uses _requested_agent directly and _failover_candidates prepends that primary before the admitted filter shapes only the failover pool. A conduct request naming a real, not-structured-ready model can still reach it whenever any other admitted agent keeps the set non-empty.

Open in Devin Review

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

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