Repository navigation
JVNAUTOSCI-2588: enforce database work within MCP deadlines - #321
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enforces that internal MCP transport hard deadlines also bound nested MongoDB work by propagating the remaining deadline into PyMongo’s client-side operation timeout (CSOT), ensuring timed-out database handlers release their bounded worker promptly and cannot later rewrite a terminal turn outcome.
Changes:
- Wrap internal MCP handlers in a PyMongo CSOT context using the remaining transport budget, reserving a small unwind interval to avoid swallowed database timeouts presenting as “completed” payloads.
- Classify Mongo CSOT expiry/admission refusal as terminal
tool_timeoutoutcomes and ensure these do not produce late-result records. - Add regression tests and document the runtime semantics in the VWL manual; adjust an orchestrator timing assertion to key off transport span duration.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/backend/test_orchestrator_tool_call_validation.py | Updates timeout timing assertion to use transport duration to avoid first-run module-init noise. |
| tests/backend/test_internal_mcp_transport_deadlines.py | Adds regression coverage for CSOT deadline propagation, classification, and worker release semantics. |
| src/backend/integrations/internal_mcp/transport.py | Implements CSOT propagation/reserve logic and deadline-based timeout reclassification. |
| docs/engineering/von_workflow_language_manual.md | Documents the new CSOT propagation and unwind-reserve semantics in workflow runtime behavior. |
Comment on lines
+190
to
+203
| details = getattr(exc, "details", None) | ||
| detail_message = ( | ||
| str(details.get("errmsg") or "") | ||
| if isinstance(details, Mapping) | ||
| else "" | ||
| ) | ||
| if _MONGO_CSOT_ADMISSION_REFUSAL_MARKER in ( | ||
| f"{exc} {detail_message}".lower() | ||
| ): | ||
| return True | ||
| return ( | ||
| scope.remaining_seconds | ||
| <= _MONGO_DEADLINE_CLASSIFICATION_TOLERANCE_SEC | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
tool_timeout, including caught error mappings, without changing ordinary earlier database errors.Root cause
The existing transport deadline bounded the caller but did not propagate the same budget into nested PyMongo operations. A timed-out Vontology read could therefore continue through independent driver timeouts while retaining one of the bounded handler workers. Some legacy handlers also catch every database exception and return an error mapping, which could make a CSOT expiry appear to be a completed handler result.
User and developer impact
Slow internal MCP database reads now terminate within the generic tool deadline, release their isolation worker, remain a typed and recoverable non-success, and cannot later rewrite the turn. This is transport support code only; it adds no arXiv, paper, entity-retrieval, or other domain-specific policy.
Validation
max_prompt_char_countremains unchanged.git diff --check: passed.live-kb-prompt-b4f058a0-1e05-459f-adf5-65d2b148ec5f, executionmcp_ab1f822c66184bbc85d3717311e245c8; typedtool_timeoutin 19.929 s, terminal turn completion, recovery affordances retained, and no late-result record.live-kb-prompt-a20bf740-8d6e-43f0-95c7-55c430077ac0;get_predicate_incidencecompleted successfully in 1.182 s.