Repository navigation
refactor(ai): default impls on AIProviderAdapter — minimal adapter is 4 methods - #1667
Merged
Merged
Conversation
… 4 methods AIProviderAdapter required ~10 methods, so every new provider and every test fixture boilerplated the long tail with identical canned values — the cv::Algorithm anti-pattern (the interface should make the COMMON case trivial). This was the concrete friction that made the deliberation acts-loop test (task #15) heavy enough to defer. Give the rarely-overridden methods sensible defaults so a minimal adapter is just provider_id + name + default_model + generate_text: - capabilities() -> AdapterCapabilities::text_only() (new constructor) - api_style() -> Local - initialize() -> Ok(()) - shutdown() -> Ok(()) - health_check() -> HealthStatus::healthy() (new constructor) - get_available_models() -> [] (ModelInfo has no defaults by design, so the honest default is "no catalog," not a synthesized entry) Mirrors how the trait ALREADY defaults warmup / create_embedding / device_type / supports / lora_* — the CBAR "for free" shape: minimal required surface, sensible defaults, override only what differs. Cloud adapters override api_style/health_check/get_available_models; local model adapters override initialize/shutdown/warmup. No production adapter changes behavior (they all override these explicitly already). Boy-scout: collapse the test StubAdapter to the 4 required methods + supports_model, proving the defaults via the existing registry tests, and add minimal_adapter_inherits_sensible_defaults asserting each default. Coordinated on airc: BigMama confirmed no collision (she's in client/ + continuum-airc-protocol, nowhere near core/ai/adapter.rs) and endorsed the cut as the right elegance. Co-Authored-By: Claude Opus 4.8 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 17, 2026
…gance pass Activates task #15: the speaks→ACTS path now has end-to-end behavioral coverage with deterministic doubles, and the loop itself is refined. Tests (llm_deliberation_faculty): - persona_acts_then_speaks_threading_tool_results — model requests a tool → executor runs it → result threaded back → model re-generates → its post-tool text is the Speak verdict. Asserts the right tool ran, the loop re-generated (2 model calls), and the re-prompt carried the tool RESULT back (the agent transcript). The case that proves a persona can act on what its tools returned, not just speak. - tools_without_executor_stay_speak_only — the can_act gate: tools authorized but no executor → tools inert, single generate, no tool round. Backward-compat guard. Test doubles are LEAN thanks to the AIProviderAdapter default impls (#1667): ScriptedAdapter is 4 methods (canned response sequence + records requests); RecordingExecutor records the calls it ran. That boilerplate was the exact friction that made this test heavy enough to defer. Elegance pass on the loop (Joel: "elegant structs, good generics, adaptability"): - Extracted try_tool_round() — owns the whole can_act gate (authorized tools AND executor AND a non-empty tool-use response), runs the batch, threads the agent transcript, returns whether to re-generate. The loop body is now generate → maybe act → re-generate, bounded. - Extracted verdict() — text → Contribution in one place. - Added ChatMessage::assistant_tool_use(&[ToolCall]) and ChatMessage::tool_results(&[ToolResult]) — the two agent-transcript turn shapes the loop built inline now live as reusable constructors on ChatMessage (one place per concern; any future agent loop reuses them). Co-Authored-By: Claude Opus 4.8 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 20, 2026
…ned (#1665) * feat(cognition): deliberation agent loop — the speaks→acts capability (dormant) The LlmDeliberationFaculty can now ACT, not just speak: with an authorized tool set (NativeToolSpec) + an injected ToolExecutor, contribute() runs the agent loop — generate → if finish_reason=ToolUse, execute_native_batch the structured tool_calls → thread the ToolResults back as ContentPart::ToolResult → re-generate → until a final text Decision (bounded by max_tool_iterations; a turn is bounded work, not an open agent). Structured ContentPart contract, NOT text-parsing (per PERSONA-COGNITION-PIPELINE.md). ToolExecutor is injected (trait) — TS-IPC impl in prod, mock in tests; the loop is impl-agnostic. DORMANT + SAFE: backward-compatible — with no tools/executor (the current build_workspace_cycle default) the loop runs exactly once with tools:None and returns the same verdict as before. The existing deliberates_through_a_real_adapter test passes unchanged through the new loop (speak-only path regression-validated). The acting branch cannot fire in production until a persona is wired with tools + an executor. FOLLOW-UP (the activation slice, gated): (1) supervisor wires the persona's authorized NativeToolSpec set + a concrete ToolExecutor (TsIpcToolExecutor) into build_workspace_cycle; (2) the acting-path behavioral test (scripted adapter returning tool_use→text + a mock executor, asserting the loop executes + threads + decides); (3) thread the real session/context ids into tool_context() (nil today). Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(cognition): behavioral test for the deliberation acts-loop + elegance pass Activates task #15: the speaks→ACTS path now has end-to-end behavioral coverage with deterministic doubles, and the loop itself is refined. Tests (llm_deliberation_faculty): - persona_acts_then_speaks_threading_tool_results — model requests a tool → executor runs it → result threaded back → model re-generates → its post-tool text is the Speak verdict. Asserts the right tool ran, the loop re-generated (2 model calls), and the re-prompt carried the tool RESULT back (the agent transcript). The case that proves a persona can act on what its tools returned, not just speak. - tools_without_executor_stay_speak_only — the can_act gate: tools authorized but no executor → tools inert, single generate, no tool round. Backward-compat guard. Test doubles are LEAN thanks to the AIProviderAdapter default impls (#1667): ScriptedAdapter is 4 methods (canned response sequence + records requests); RecordingExecutor records the calls it ran. That boilerplate was the exact friction that made this test heavy enough to defer. Elegance pass on the loop (Joel: "elegant structs, good generics, adaptability"): - Extracted try_tool_round() — owns the whole can_act gate (authorized tools AND executor AND a non-empty tool-use response), runs the batch, threads the agent transcript, returns whether to re-generate. The loop body is now generate → maybe act → re-generate, bounded. - Extracted verdict() — text → Contribution in one place. - Added ChatMessage::assistant_tool_use(&[ToolCall]) and ChatMessage::tool_results(&[ToolResult]) — the two agent-transcript turn shapes the loop built inline now live as reusable constructors on ChatMessage (one place per concern; any future agent loop reuses them). Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(cognition): abstain instead of fabricating PASS when the model is cut off Adversarial review (PR #1665) caught a no-fallbacks-doctrine violation: when the model hit the tool-iteration cap (or had no executor) and returned finish_reason=ToolUse with EMPTY text, the loop fell through to verdict("") → decision_from_response("") → Decision::Pass — silently turning a model cut off mid-reasoning into "chose silence (PASS)". Silence must be the model's choice, never a substrate artifact (same rule the inference-failure branch already honors by returning None). Fix: when the model still wanted to act but we're not acting AND it left no verdict text, abstain (return None) + warn at the cap boundary (OBSERVABILITY-AS-SUBSTRATE: hitting the ceiling is a load-bearing decision). Non-empty text is still honored — a model that says "PASS" alongside a tool call expressed a real verdict (tools_without_executor_stay_speak_only stays green). Regression test added: tool_want_with_empty_text_and_no_executor_abstains. All 5 deliberation tests pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
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
AIProviderAdapterrequired ~10 methods, so every new provider and every test fixture boilerplated the long tail with identical canned values — thecv::Algorithmanti-pattern (the interface should make the common case trivial). This was the concrete friction that made the deliberation acts-loop test (task #15) heavy enough to defer.Give the rarely-overridden methods sensible defaults so a minimal adapter is just
provider_id+name+default_model+generate_text:capabilities()AdapterCapabilities::text_only()(new constructor)api_style()Localinitialize()Ok(())shutdown()Ok(())health_check()HealthStatus::healthy()(new constructor)get_available_models()[]—ModelInfohas no defaults by design, so the honest default is "no catalog," not a synthesized entryMirrors how the trait already defaults
warmup/create_embedding/device_type/supports/lora_*— the CBAR "for free" shape: minimal required surface, sensible defaults, override only what differs.Why it's safe
No production adapter changes behavior — cloud adapters already override
api_style/health_check/get_available_models; local model adapters already overrideinitialize/shutdown/warmup.Boy-scout
Collapsed the test
StubAdapterfrom 10 methods to the 4 required +supports_model, which now proves the defaults via the existing registry tests, plus a dedicatedminimal_adapter_inherits_sensible_defaultsasserting each default.Coordination
Flagged on airc per Joel's standing norm ("if an adapter's a PITA, talk amongst yourselves"). BigMama confirmed no collision (she's in
client/+continuum-airc-protocol, nowhere nearcore/ai/adapter.rs) and endorsed the cut.Test
cargo test -p continuum-core --lib --features metal,accelerate,test-fixtures ai::adapter::tests→ 5 passed. Clippy clean on touched files.🤖 Generated with Claude Code