feat(runtime): add decision model contracts - #1739
Merged
Merged
Conversation
Introduce provider-neutral DecisionModel request/result types, a fail-open structured-generator adapter, and isolated decision inference configuration. The new runtime switch defaults off and does not connect the decision model to existing Memory or Handoff behavior yet. Validation: - uv run pytest tests/builtin/runtime/test_decision_model.py tests/test_server_generation.py -q - uv run pytest tests/e2e/test_builtin_runtime.py -q - uv run ruff check src/powercontext/builtin/runtime/decision_model.py src/powercontext/builtin/runtime/config.py src/powercontext/builtin/runtime/__init__.py tests/builtin/runtime/test_decision_model.py tests/test_server_generation.py - uv run ty check src/powercontext/builtin/runtime/decision_model.py src/powercontext/builtin/runtime/config.py tests/builtin/runtime/test_decision_model.py tests/test_server_generation.py Co-authored-by: OmX <omx@oh-my-codex.dev>
AsperforMias
previously requested changes
Sep 25, 2026
AsperforMias
left a comment
Collaborator
There was a problem hiding this comment.
Please validate model-selected IDs against the request options before returning a successful decision. The inline finding includes a reproducer.
Design note (non-blocking): #1739 and #1740 share a base and introduce different contracts in the same module; please reconcile the intended contract before landing both. The linked issues #1643, #1644, #1645, #1647 and #1648 still require their domain implementations and experiments. This PR accurately describes itself as foundation-only, so those are follow-up scope, not additional blockers here.
Reject non-fallback decision outputs that omit a selected option, select an option outside the request, or report scores for unknown option IDs. Invalid provider output now fails open with an explicit invalid_output fallback while preserving usage. Tested: uv run --no-sync pytest tests/builtin/runtime/test_decision_model.py -q; ruff check/format --check decision_model and test; ty check decision_model and test
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.
Which issue or RFC does this PR close?
Refs #1643, #1644, #1645, #1647, #1648.
This is a foundation PR only; it does not close any of those issue-level behaviors.
Rationale for this change
The Jev/Laya investigation points to one reusable architecture rule for PowerContext: decision models should be provider-neutral runtime collaborators, invoked from deterministic code paths and allowed to fail open. This PR adds that narrow foundation before any Memory, Handoff, Experience, or Skill policy uses it.
What changes are included in this PR?
DecisionModelcontracts underpowercontext.builtin.runtime:DecisionModelRequestDecisionModelResultStructuredDecisionModel, a small adapter that wraps an existingStructuredGeneratorand converts stable inference failures into explicit fail-open results.RuntimeConfig.decision_assistance_enabledswitch.This PR intentionally does not connect decision models to Memory writes, Memory reranking, Handoff generation, Handoff acknowledgement, OpenAPI schemas, persistence, or prompt capabilities.
Are there any user-facing changes?
No behavior change is expected by default. The new configuration fields are inert until a later PR wires a decision model into a specific runtime policy path. There are no persisted format, HTTP API, OpenAPI, or generated-client changes.
How was this change tested?
uv run pytest tests/builtin/runtime/test_decision_model.py tests/test_server_generation.py -quv run pytest tests/e2e/test_builtin_runtime.py -quv run ruff check src/powercontext/builtin/runtime/decision_model.py src/powercontext/builtin/runtime/config.py src/powercontext/builtin/runtime/__init__.py tests/builtin/runtime/test_decision_model.py tests/test_server_generation.pyuv run ty check src/powercontext/builtin/runtime/decision_model.py src/powercontext/builtin/runtime/config.py tests/builtin/runtime/test_decision_model.py tests/test_server_generation.pyAI usage statement
Implemented with OpenAI Codex in the Codex desktop app, based on the Jev/Laya/OpenClaw/Hermes research notes and repository-local code inspection.