Fix adapter multimodal spawn contract#1928
Conversation
There was a problem hiding this comment.
Sorry @chernistry, you have reached your weekly rate limit of 2500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Sonar insights (advisory, no merge-block)Snapshot of
Run This comment is a soft signal. The Sonar scan runs on push to |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds an optional ChangesMultimodal context gating across adapter layer
🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Review-bot acknowledgement summary
All must-address findings are resolved or acknowledged. |
|
bernstein doctor observe for PR #1928 ( sonar -- WARN (project bernstein)
code-scanning -- OK (22 open alert(s))
Skipped backends (credentials not configured)
See docs/observability/unified-doctor.md for backend setup notes. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/bernstein/adapters/conformance.py (1)
568-579:⚠️ Potential issue | 🟠 Major | ⚡ Quick winComplete scaffold
spawn()signature to match the base adapter contract.At Line 576-Line 579, the template adds
multimodal_contextbut still omitsbudget_multiplierandsystem_addendum. Scaffolded adapters from this template can fail at runtime whenspawn()is invoked with the full contract kwargs.Proposed fix
def spawn( self, *, prompt: str, workdir: Path, model_config: ModelConfig, session_id: str, mcp_config: dict[str, Any] | None = None, timeout_seconds: int = 1800, task_scope: str = "medium", + budget_multiplier: float = 1.0, + system_addendum: str = "", multimodal_context: Any | None = None, ) -> SpawnResult:As per coding guidelines,
src/bernstein/adapters/**/*.py: "Implement CLI agent adapters following the base adapter contract defined in base.py and _contract.py".Also applies to: 593-593
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/bernstein/adapters/conformance.py` around lines 568 - 579, The spawn() signature in the adapter is missing required parameters from the base adapter contract, causing runtime failures; update the spawn method (the function named spawn that returns SpawnResult and accepts ModelConfig) to include the missing keyword args budget_multiplier and system_addendum (and keep existing multimodal_context), so its signature matches the base contract used by callers; ensure the implementation accepts and forwards these args (or provides sensible defaults) wherever spawn is invoked or delegated.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/test_adapter_consistency.py`:
- Around line 99-102: The test currently only checks that adapter.spawn has a
multimodal_context parameter; update test_spawn_has_optional_multimodal_context
to also assert that
inspect.signature(adapter.spawn).parameters["multimodal_context"].default is
None (to ensure it’s optional) and optionally assert that the parameter.kind
indicates it is keyword-only if you want that constraint; reference the
adapter.spawn method and the "multimodal_context" parameter when adding these
assertions.
- Around line 172-176: The test currently parametrizes with "_TESTABLE_ADAPTERS"
which supplies shared mutable adapter instances (adapter_name, adapter) and can
leak state; change the parametrize to pass only adapter_name (e.g., param
"adapter_name" with ids from _TESTABLE_ADAPTERS names) and inside the test
function instantiate a fresh adapter per-case (use your adapter
factory/constructor or a helper like create_adapter(adapter_name) or a mapping
that constructs a new instance) so each test gets a new adapter object instead
of reusing the shared "adapter" from _TESTABLE_ADAPTERS.
---
Outside diff comments:
In `@src/bernstein/adapters/conformance.py`:
- Around line 568-579: The spawn() signature in the adapter is missing required
parameters from the base adapter contract, causing runtime failures; update the
spawn method (the function named spawn that returns SpawnResult and accepts
ModelConfig) to include the missing keyword args budget_multiplier and
system_addendum (and keep existing multimodal_context), so its signature matches
the base contract used by callers; ensure the implementation accepts and
forwards these args (or provides sensible defaults) wherever spawn is invoked or
delegated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 63fc31c9-96d2-44d1-81cb-05e92d1c40c5
📒 Files selected for processing (50)
src/bernstein/adapters/aichat.pysrc/bernstein/adapters/aider.pysrc/bernstein/adapters/amp.pysrc/bernstein/adapters/auggie.pysrc/bernstein/adapters/autohand.pysrc/bernstein/adapters/base.pysrc/bernstein/adapters/caching_adapter.pysrc/bernstein/adapters/charm.pysrc/bernstein/adapters/cline.pysrc/bernstein/adapters/clm.pysrc/bernstein/adapters/cloudflare_agents.pysrc/bernstein/adapters/codebuff.pysrc/bernstein/adapters/codex.pysrc/bernstein/adapters/cody.pysrc/bernstein/adapters/composio.pysrc/bernstein/adapters/conformance.pysrc/bernstein/adapters/continue_dev.pysrc/bernstein/adapters/copilot.pysrc/bernstein/adapters/cursor.pysrc/bernstein/adapters/devin_terminal.pysrc/bernstein/adapters/droid.pysrc/bernstein/adapters/forge.pysrc/bernstein/adapters/generic.pysrc/bernstein/adapters/goose.pysrc/bernstein/adapters/gptme.pysrc/bernstein/adapters/hermes.pysrc/bernstein/adapters/iac.pysrc/bernstein/adapters/junie.pysrc/bernstein/adapters/kilo.pysrc/bernstein/adapters/kimi.pysrc/bernstein/adapters/kiro.pysrc/bernstein/adapters/letta_code.pysrc/bernstein/adapters/manager.pysrc/bernstein/adapters/mistral.pysrc/bernstein/adapters/mock.pysrc/bernstein/adapters/ollama.pysrc/bernstein/adapters/open_interpreter.pysrc/bernstein/adapters/openai_agents.pysrc/bernstein/adapters/opencode.pysrc/bernstein/adapters/openhands.pysrc/bernstein/adapters/pi.pysrc/bernstein/adapters/plandex.pysrc/bernstein/adapters/plugin_sdk.pysrc/bernstein/adapters/q_dev.pysrc/bernstein/adapters/qwen.pysrc/bernstein/adapters/ralphex.pysrc/bernstein/adapters/rovo.pysrc/bernstein/core/agents/multimodal.pytests/unit/test_adapter_consistency.pytests/unit/test_caching_adapter.py
bot-ack: 3289888566
Summary
multimodal_contextto concrete adapterspawn()overrides so they match the base adapter contract.CachingAdapterand bypasses text-only response cache hits when attachments are present.Verification
uv run pytest tests/unit/test_adapter_consistency.py -q --tb=shortuv run pytest tests/unit/test_caching_adapter.py -q --tb=shortuv run ruff format --check src/bernstein/adapters src/bernstein/core/agents/multimodal.py tests/unit/test_adapter_consistency.py tests/unit/test_caching_adapter.pyuv run ruff check src/bernstein/adapters src/bernstein/core/agents/multimodal.py tests/unit/test_adapter_consistency.py tests/unit/test_caching_adapter.pyuv run pyright --project pyrightconfig.strict.jsongit diff --checkRefs #1785
Summary by CodeRabbit
New Features
Tests