Let the project's settings pick loop-claude's models
This commit is contained in:
+8
-6
@@ -16,8 +16,8 @@ typing anything. Before a handoff every worktree is marked trusted in ~/.claude.
|
|||||||
Each project has one session, "A ~/code/<path> auto-mode" (the absolute path outside ~/code),
|
Each project has one session, "A ~/code/<path> auto-mode" (the absolute path outside ~/code),
|
||||||
resumed while present and deleted when the chunk finishes. Its transcript is archived under
|
resumed while present and deleted when the chunk finishes. Its transcript is archived under
|
||||||
$AUTO_MODE_TRANSCRIPTS (default ~/.claude/auto-mode-transcripts/<path>/) whenever the human is asked
|
$AUTO_MODE_TRANSCRIPTS (default ~/.claude/auto-mode-transcripts/<path>/) whenever the human is asked
|
||||||
and when the chunk finishes. JUDGE_MODEL and WORKER_MODEL override the models (default
|
and when the chunk finishes. JUDGE_MODEL and WORKER_MODEL override the model the project's
|
||||||
claude-opus-5-5). A change to this file takes effect at the next round boundary.
|
Claude Code settings pick. A change to this file takes effect at the next round boundary.
|
||||||
"""
|
"""
|
||||||
import glob
|
import glob
|
||||||
import json
|
import json
|
||||||
@@ -29,11 +29,9 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
ARCHIVE = os.path.expanduser(os.environ.get("AUTO_MODE_TRANSCRIPTS", "~/.claude/auto-mode-transcripts"))
|
ARCHIVE = os.path.expanduser(os.environ.get("AUTO_MODE_TRANSCRIPTS", "~/.claude/auto-mode-transcripts"))
|
||||||
JUDGE_MODEL = os.environ.get("JUDGE_MODEL", "claude-opus-5-5")
|
|
||||||
ROUND = "LOOP_CLAUDE_ROUND"
|
ROUND = "LOOP_CLAUDE_ROUND"
|
||||||
SESSION_NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
SESSION_NAMESPACE = uuid.UUID("64fb586b-d926-4bb3-a44c-c903e86d3eec")
|
||||||
SOURCE = open(__file__, encoding="utf-8").read()
|
SOURCE = open(__file__, encoding="utf-8").read()
|
||||||
WORKER_MODEL = os.environ.get("WORKER_MODEL", "claude-opus-5-5")
|
|
||||||
|
|
||||||
JUDGE_RULES = (
|
JUDGE_RULES = (
|
||||||
"Decide whether the human must now be interrupted. ask=true when any of these appear:\n"
|
"Decide whether the human must now be interrupted. ask=true when any of these appear:\n"
|
||||||
@@ -212,6 +210,10 @@ def trust(paths):
|
|||||||
print("trusted for the handoff: " + ", ".join(granted), file=sys.stderr)
|
print("trusted for the handoff: " + ", ".join(granted), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
|
def model(variable):
|
||||||
|
return ["--model", os.environ[variable]] if os.environ.get(variable) else []
|
||||||
|
|
||||||
|
|
||||||
def worker_args(task, name, session_id, resuming):
|
def worker_args(task, name, session_id, resuming):
|
||||||
if resuming:
|
if resuming:
|
||||||
start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session_id)]
|
start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session_id)]
|
||||||
@@ -222,7 +224,7 @@ def worker_args(task, name, session_id, resuming):
|
|||||||
"--output-format", "stream-json",
|
"--output-format", "stream-json",
|
||||||
"--permission-mode", "bypassPermissions",
|
"--permission-mode", "bypassPermissions",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
"--model", WORKER_MODEL,
|
*model("WORKER_MODEL"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -261,7 +263,7 @@ def judge(task, premises, transcript):
|
|||||||
args = [
|
args = [
|
||||||
"-p",
|
"-p",
|
||||||
"--json-schema", json.dumps(JUDGE_SCHEMA),
|
"--json-schema", json.dumps(JUDGE_SCHEMA),
|
||||||
"--model", JUDGE_MODEL,
|
*model("JUDGE_MODEL"),
|
||||||
"--no-session-persistence",
|
"--no-session-persistence",
|
||||||
"--output-format", "json",
|
"--output-format", "json",
|
||||||
"--permission-mode", "bypassPermissions",
|
"--permission-mode", "bypassPermissions",
|
||||||
|
|||||||
@@ -66,6 +66,16 @@ class WorkerArgs(unittest.TestCase):
|
|||||||
self.assertNotIn("--name", args)
|
self.assertNotIn("--name", args)
|
||||||
self.assertNotIn("paint the fence", args[1])
|
self.assertNotIn("paint the fence", args[1])
|
||||||
|
|
||||||
|
def test_the_project_settings_pick_the_model_unless_the_environment_names_one(self):
|
||||||
|
os.environ.pop("WORKER_MODEL", None)
|
||||||
|
self.assertNotIn("--model", loop.worker_args("t", "n", SESSION_ID, resuming=False))
|
||||||
|
os.environ["WORKER_MODEL"] = "claude-fable-5-1"
|
||||||
|
try:
|
||||||
|
args = loop.worker_args("t", "n", SESSION_ID, resuming=False)
|
||||||
|
finally:
|
||||||
|
del os.environ["WORKER_MODEL"]
|
||||||
|
self.assertEqual(args[args.index("--model") + 1], "claude-fable-5-1")
|
||||||
|
|
||||||
|
|
||||||
class JudgePrompt(unittest.TestCase):
|
class JudgePrompt(unittest.TestCase):
|
||||||
def test_hands_the_judge_the_tail_of_a_long_transcript(self):
|
def test_hands_the_judge_the_tail_of_a_long_transcript(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user