From 1701f9c0708230cc29177305e16d01d6513e5582 Mon Sep 17 00:00:00 2001 From: Andrei Savu Date: Mon, 16 Feb 2026 22:31:21 -0800 Subject: [PATCH] Upgrade to weakincentives v0.27.0 and apply breaking changes Move task_completion_checker from ClaudeAgentSDKClientConfig to PromptTemplate, matching the new prompt-scoped declaration model. Update imports to use weakincentives.prompt for TaskCompletionContext and TaskCompletionResult. Co-Authored-By: Claude Opus 4.6 --- pyproject.toml | 4 ++-- src/trivia_agent/adapters.py | 21 +++++++++------------ src/trivia_agent/agent_loop.py | 4 +++- tests/trivia_agent/test_adapters.py | 19 ++++++++----------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c84acbe..bf6e242 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ include = ["src"] typeCheckingMode = "strict" [tool.uv.sources] -weakincentives = { git = "https://github.com/weakincentives/weakincentives.git", tag = "v0.26.0" } +weakincentives = { git = "https://github.com/weakincentives/weakincentives.git", tag = "v0.27.0" } [dependency-groups] dev = [ @@ -51,6 +51,6 @@ dev = [ "pytest-timeout", "pyright", "ruff", - "weakincentives[wink] @ git+https://github.com/weakincentives/weakincentives.git@v0.26.0", + "weakincentives[wink] @ git+https://github.com/weakincentives/weakincentives.git@v0.27.0", "pytest-rerunfailures>=16.1", ] diff --git a/src/trivia_agent/adapters.py b/src/trivia_agent/adapters.py index 169141a..009fbb1 100644 --- a/src/trivia_agent/adapters.py +++ b/src/trivia_agent/adapters.py @@ -5,7 +5,7 @@ handles task completion, and manages execution isolation. Key components: - - ``SimpleTaskCompletionChecker``: Pass-through completion checker + - ``SimpleTaskCompletionChecker``: Pass-through completion checker (used by prompt) - ``create_adapter``: Factory function to build configured adapters The default model is Claude Sonnet, accessed via the "sonnet" alias. @@ -20,12 +20,9 @@ from typing import TYPE_CHECKING -from weakincentives.adapters.claude_agent_sdk import ( - ClaudeAgentSDKAdapter, - TaskCompletionContext, - TaskCompletionResult, -) +from weakincentives.adapters.claude_agent_sdk import ClaudeAgentSDKAdapter from weakincentives.adapters.claude_agent_sdk.config import ClaudeAgentSDKClientConfig +from weakincentives.prompt import TaskCompletionContext, TaskCompletionResult from trivia_agent.models import TriviaResponse @@ -87,15 +84,17 @@ def create_adapter( """Create and configure a Claude Agent SDK adapter for the trivia agent. Factory function that assembles all components needed to run the trivia - agent: model selection, task completion checking, isolation configuration, - and working directory setup. The returned adapter is ready to be passed - to a WINK AgentLoop or EvalLoop. + agent: model selection, isolation configuration, and working directory + setup. The returned adapter is ready to be passed to a WINK AgentLoop + or EvalLoop. The adapter is configured with: - Model: Claude Sonnet (via the "sonnet" alias) - - Completion checker: SimpleTaskCompletionChecker (always succeeds) - Response type: TriviaResponse (structured output schema) + Note: Task completion checking is declared on the PromptTemplate (see + agent_loop.py), not on the adapter config. + Args: isolation: Optional isolation configuration that controls the agent's execution environment. When provided, specifies: @@ -119,9 +118,7 @@ def create_adapter( >>> # Use adapter with AgentLoop >>> loop = AgentLoop.create(adapter=adapter, sections=[...]) """ - checker = SimpleTaskCompletionChecker() client_config = ClaudeAgentSDKClientConfig( - task_completion_checker=checker, isolation=isolation, cwd=cwd, ) diff --git a/src/trivia_agent/agent_loop.py b/src/trivia_agent/agent_loop.py index 4edaeb5..922f2eb 100644 --- a/src/trivia_agent/agent_loop.py +++ b/src/trivia_agent/agent_loop.py @@ -37,7 +37,7 @@ from weakincentives.runtime.mailbox import Mailbox from weakincentives.skills import SkillMount -from trivia_agent.adapters import create_adapter +from trivia_agent.adapters import SimpleTaskCompletionChecker, create_adapter from trivia_agent.config import load_redis_settings from trivia_agent.feedback import build_feedback_providers from trivia_agent.isolation import API_KEY_ENV, has_auth, resolve_isolation_config, resolve_skills @@ -193,6 +193,7 @@ def build_prompt_template( build_task_examples_section(), # Multi-step workflow examples ], feedback_providers=build_feedback_providers(), + task_completion_checker=SimpleTaskCompletionChecker(), ) @@ -337,6 +338,7 @@ def prepare( workspace_section, # Session-bound workspace access ], feedback_providers=build_feedback_providers(), + task_completion_checker=SimpleTaskCompletionChecker(), ) # Determine overrides tag from experiment diff --git a/tests/trivia_agent/test_adapters.py b/tests/trivia_agent/test_adapters.py index db04e43..32ab092 100644 --- a/tests/trivia_agent/test_adapters.py +++ b/tests/trivia_agent/test_adapters.py @@ -2,10 +2,8 @@ from unittest.mock import MagicMock -from weakincentives.adapters.claude_agent_sdk import ( - ClaudeAgentSDKAdapter, - TaskCompletionResult, -) +from weakincentives.adapters.claude_agent_sdk import ClaudeAgentSDKAdapter +from weakincentives.prompt import TaskCompletionResult from trivia_agent.adapters import SimpleTaskCompletionChecker, create_adapter @@ -44,14 +42,13 @@ def test_adapter_uses_default_model(self) -> None: assert adapter is not None def test_adapter_has_client_config(self) -> None: - """Test that adapter is configured with task completion checker.""" + """Test that adapter is configured with client config.""" adapter = create_adapter() - # Verify adapter was created with client config + # Verify adapter was created with client config (no task_completion_checker — + # that's now on the PromptTemplate) assert adapter._client_config is not None - assert adapter._client_config.task_completion_checker is not None - def test_adapter_task_completion_checker_is_simple_checker(self) -> None: - """Test that the task completion checker is SimpleTaskCompletionChecker.""" + def test_adapter_no_task_completion_on_client_config(self) -> None: + """Test that task completion checker is not on client config (moved to prompt).""" adapter = create_adapter() - checker = adapter._client_config.task_completion_checker - assert isinstance(checker, SimpleTaskCompletionChecker) + assert not hasattr(adapter._client_config, "task_completion_checker")