Add an LLM steering brain behind the DecidePort seam#546
Merged
Conversation
Introduce LlmDecidePort, a fifth DecidePort substrate that asks an LLM for the next autonomous-experiment action (Measure a next point, or Stop) given the full SteeringEvidence. The DecidePort docstring already names an LLM as an intended brain and the LLM port names a Strategy consumer; this fills that seam without a new aggregate, agent seed, or subscriber, so it does not touch the agent-subscriber Reaction-widening trigger. The adapter is homed in cora.operation.adapters (not cora.agent.prompts) because tach forbids cora.operation from importing cora.agent; it consumes only the LLM port and the shared steering value types. It is stateless (full evidence handed over each call, fit for replay), translates the LLMError family into the Decide*Error taxonomy the conduct loop already folds into a deferred steering decision, and guards against a hallucinated next_point that names an axis outside the SteeringSpace. SteeringAdvice self-validation catches a malformed verdict/point pairing and out-of-range confidence. The evidence is serialized via canonical_json_bytes so the prompt-cache prefix stays byte-stable across write-time and replay-time. Wired as the "llm" substrate in build_decide_port via an injected llm port (ValueError when absent, mirroring the bo-missing guard); both conduct_until_advised handlers pass deps.llm through. Kept off the wire (WireDecideSubstrate unchanged) and not yet the ExperimentSteerer default; those are deliberate later stages.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Summary
LlmDecidePort, a fifthDecidePortsubstrate that asks an LLM for the next autonomous-experiment action (Measure a next point, or Stop) from the fullSteeringEvidence. TheDecidePortdocstring already named an LLM as an intended brain and theLLMport named a Strategy consumer; this fills that seam.cora.operation.adapters(notcora.agent.prompts) because tach forbidscora.operation -> cora.agent; consumes only the LLM port + shared steering value types.Design
LLMErrorfamily into theDecide*Errortaxonomy the conduct loop already folds into a deferred steering decision (never crashes the loop).next_pointnaming an axis outside theSteeringSpace;SteeringAdviceself-validation catches a malformed verdict/point pairing and out-of-range confidence.canonical_json_bytesso the prompt-cache prefix stays byte-stable across write/replay.llmsubstrate inbuild_decide_portvia an injectedllmport (ValueError when absent, mirroring thebo-missing guard); bothconduct_until_advisedhandlers passdeps.llmthrough.Scope (Stage 0)
WireDecideSubstrateunchanged) and NOT yet theExperimentSteererdefault; those are deliberate later stages.Test plan
test_llm_decide_port.py): Measure/Stop, full-error-mapping table, unknown verdict, Measure-without-point, hallucinated-axis guard, factory arm + llm-required guard.operation -> infrastructure.ports.llmimport legal + decide-port purity holds + canonical-json single-source rule).build_decide_port(..., llm=FakeLLM())+advise_next.🤖 Generated with Claude Code