diff --git a/crafting_table/patcher.py b/crafting_table/patcher.py index 1a2c6ab..2fff823 100644 --- a/crafting_table/patcher.py +++ b/crafting_table/patcher.py @@ -98,6 +98,12 @@ class PatcherConfig: # HTTP timeout margin — clawdforge adds an internal margin, but we cap # transport-level too for hung connections. http_timeout_secs: int = 600 + # Model passed to clawdforge on session create. Pinned to "opus" by + # default — code-work prompts (read finding context, write a unified + # diff that doesn't break the verify recipe) reward Opus's longer + # context + deeper reasoning. Override via CRAFTING_PATCHER_MODEL env + # if you want sonnet for cost reasons. + model: str = "opus" @classmethod def from_env(cls, env: dict[str, str] | None = None) -> "PatcherConfig | None": @@ -127,6 +133,7 @@ class PatcherConfig: auto_patch_branch_prefix=e.get( "CRAFTING_PATCHER_BRANCH_PREFIX", "crafting-table/auto/" ), + model=e.get("CRAFTING_PATCHER_MODEL", "opus"), ) @@ -210,9 +217,12 @@ class ClawdforgeClient: self, *, agent: str = "claude", + model: str | None = None, meta: dict[str, Any] | None = None, ) -> dict[str, Any]: body: dict[str, Any] = {"agent": agent} + if model is not None: + body["model"] = model if meta is not None: body["meta"] = meta async with httpx.AsyncClient(timeout=self.timeout_secs) as ac: @@ -657,6 +667,7 @@ class Patcher: try: session_payload = await self.clawdforge.create_session( agent="claude", + model=self.config.model, meta={ "crafting_table_job_id": job["id"], "finding_id": finding_id,