sprag-cli 3.126.0 → 3.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/CODEX.ko.md +6 -4
- package/docs/CODEX.md +8 -5
- package/package.json +1 -1
- package/presets/agents.json +5 -5
- package/presets/delegation/bounds.md +6 -6
- package/presets/ratchet-rules.json +2 -2
- package/src/agents.js +16 -0
- package/src/codex/delegation.js +4 -2
- package/src/delegation-guard.js +43 -4
- package/src/impl-follow.js +5 -9
- package/src/implementation-delegation.js +47 -9
package/docs/CODEX.ko.md
CHANGED
|
@@ -369,10 +369,12 @@ Codex는 현재 부모 모델과 프로바이더의 명시적 T1 매핑을 우
|
|
|
369
369
|
sprag delegate implementation --agent codex --from PARENT_MODEL --provider PROVIDER --session PARENT_SESSION_ID
|
|
370
370
|
```
|
|
371
371
|
|
|
372
|
-
기본 설정 대신 실제 부모 세션의 정보를 넘깁니다. 자식에게 설계, 수정할
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
372
|
+
기본 설정 대신 실제 부모 세션의 정보를 넘깁니다. 자식에게 목표와 이유, 확정한 설계, 수정할 파일과
|
|
373
|
+
건드리지 않을 범위, 함께 고칠 호출 지점과 사본, 따라야 할 저장소 규약, 검사할 수 있는 완료 기준,
|
|
374
|
+
대상 테스트와 전체 테스트 명령, 보고 형식, 모델 선택 이유를 전달하고, 반환된 route 줄을 메시지
|
|
375
|
+
끝에 붙입니다. 안내문은 출력 토큰 상한을 적지 않으며 범위는 수정할 파일과 완료 기준으로 정합니다.
|
|
376
|
+
`fork_turns "none"`으로 생성합니다. 메인은 `wait_agent`로 완료를 기다린 뒤 diff와 실제 테스트
|
|
377
|
+
결과를 검증합니다.
|
|
376
378
|
|
|
377
379
|
T1이 없거나 위임이 꺼져 있으면 메인이 처리합니다. haiku나 T2로 대체하지 않습니다.
|
|
378
380
|
이미 읽은 파일의 약 50줄 이하 수정도 메인에서 처리합니다. 위임 도구가 없으면 위 명령을
|
package/docs/CODEX.md
CHANGED
|
@@ -390,13 +390,16 @@ equal model capability. It never falls back to T2. Disabled delegation or an
|
|
|
390
390
|
unresolved T1 leaves the work on the main agent. Small edits of roughly 50 lines
|
|
391
391
|
in already-read files also stay on the main agent.
|
|
392
392
|
|
|
393
|
-
The child receives a self-contained specification
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
The child receives a self-contained specification: the goal and its reason, the
|
|
394
|
+
settled design, the owned files and what must stay untouched, the other callers
|
|
395
|
+
and copies that must change with it, the repository conventions that apply,
|
|
396
|
+
checkable completion criteria, the targeted and full test commands, the report
|
|
397
|
+
format and the model-selection reason. The hint states no output-token cap:
|
|
398
|
+
scope is the owned files and the completion criteria. Use `fork_turns "none"`
|
|
399
|
+
and end the child message with the returned route line. Wait with `wait_agent` (at least 120 seconds per wait), then inspect its
|
|
397
400
|
diff and actual test results. Without native subagent tools, skip the resolver
|
|
398
401
|
and report the limitation; do not launch a second Codex CLI as a substitute.
|
|
399
|
-
|
|
402
|
+
Accounting requires a child of
|
|
400
403
|
the recorded parent on the selected model/provider; an unused hint earns no
|
|
401
404
|
savings. Implementation requests are not automatically classified as cheap work.
|
|
402
405
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.127.0",
|
|
4
4
|
"description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/presets/agents.json
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"en": "Cheap runner for build, test and git commands in delegated tasks. It has no MCP tools."
|
|
61
61
|
},
|
|
62
62
|
"body": {
|
|
63
|
-
"ko": "맡은 역할: 전달받은 빌드·테스트·git 명령을 실행하고 결과를 보고합니다.\n위임받은 작업만 하고, 호출자가 프롬프트에 적은 상한(도구 호출 횟수, 출력 토큰)을 넘기지 마십시오.\n호출자 프롬프트의 언어로 간결하게 보고하십시오.\nMCP 도구나 목록에 없는 도구가 필요하면 즉시 멈추고 \"needs tools: <필요한 도구>\" 한 줄로 보고하십시오. 부모가 다시 위임합니다.\n확인하지 못한 내용은 추측하지 말고 확인하지 못했다고 말하십시오.\n전체 테스트, 빌드, 렌더처럼 프로세스를 여럿 띄우는 명령은 프로세스 상한을 걸고 실행하십시오. macOS 와 Linux 에서는 `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <명령>)` 으로
|
|
63
|
+
"ko": "맡은 역할: 전달받은 빌드·테스트·git 명령을 실행하고 결과를 보고합니다.\n위임받은 작업만 하고, 호출자가 프롬프트에 적은 상한(도구 호출 횟수, 출력 토큰)을 넘기지 마십시오.\n호출자 프롬프트의 언어로 간결하게 보고하십시오.\nMCP 도구나 목록에 없는 도구가 필요하면 즉시 멈추고 \"needs tools: <필요한 도구>\" 한 줄로 보고하십시오. 부모가 다시 위임합니다.\n확인하지 못한 내용은 추측하지 말고 확인하지 못했다고 말하십시오.\n전체 테스트, 빌드, 렌더처럼 프로세스를 여럿 띄우는 명령은 프로세스 상한을 걸고 실행하십시오. macOS 와 Linux 에서는 `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <명령>)` 으로 감싸고 Windows 에서는 그대로 실행합니다. 출력에 `spawn ... EAGAIN` 이나 `Resource temporarily unavailable` 이 보이면 테스트 실패가 아니라 프로세스 폭주이므로 명령을 다시 돌리지 말고 그 줄을 인용해 보고하십시오.",
|
|
64
64
|
"en": "Your role: run the build, test, or git commands you are given and report the result.\nDo only the delegated task, and stay within the caps (tool calls, output tokens) the caller wrote in the prompt.\nReport concisely, in the language of the caller's prompt.\nIf you need an MCP tool or any tool not on your list, stop at once and report one line: \"needs tools: <tools needed>\". The parent will delegate again.\nDo not guess at anything you could not verify; say that you could not verify it.\nRun a command that starts many processes (a full test suite, a build, a render) under a process cap: on macOS and Linux wrap it as `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <command>)`, on Windows run it as is. If the output shows `spawn ... EAGAIN` or `Resource temporarily unavailable`, that is a process runaway, not a test failure: do not rerun the command; quote that line and report."
|
|
65
65
|
}
|
|
66
66
|
},
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
"en": "Mid-tier worker for multi-step tasks and implementation handed over with a fixed design. It has no MCP tools."
|
|
111
111
|
},
|
|
112
112
|
"body": {
|
|
113
|
-
"ko": "맡은 역할: 여러 단계로 이어지는 작업과, 호출자가 설계를 확정한 구현을 맡습니다.\n위임받은 작업만
|
|
114
|
-
"en": "Your role: multi-step work and the implementation half of a design the caller already fixed.\nDo only the delegated task, and stay within the
|
|
113
|
+
"ko": "맡은 역할: 여러 단계로 이어지는 작업과, 호출자가 설계를 확정한 구현을 맡습니다.\n위임받은 작업만 하고 호출자가 프롬프트에 적은 도구 호출 상한과 범위를 지키십시오. 출력 토큰 상한은 조회와 보고에 적용됩니다. 파일을 고치는 작업에서 출력 토큰 수치는 추정치이며 중단선으로 쓰지 않습니다. 설계서에 적힌 변경과 테스트를 끝까지 마치십시오.\n파일을 고치는 작업에서는 아래를 지키십시오.\n- 함수나 값이나 형식을 바꾸기 전에 그것을 쓰는 다른 호출 지점과 사본을 검색하십시오. 함께 동작하게 고치거나 고치지 않고 둔 곳을 보고하십시오.\n- 테스트가 목록이나 등록부(환경 변수, 명령, 내보낸 이름, 사본 파일)를 강제하면 새 항목을 거기에 추가하십시오.\n- 설계가 코드와 맞지 않으면 멈추고 충돌을 보고하십시오. 다른 설계로 구현하지 마십시오.\n- 작업이 맡긴 파일만 고치고 작업 트리에 symlink, 로그, 임시 파일을 남기지 마십시오.\n- 보고하기 전에 작업이 적어 준 명령(테스트, 데모, 스크린샷)을 모두 실행하십시오. 테스트 명령이 없으면 고친 파일을 다루는 테스트를 찾아 실행하십시오. 실행하지 못한 명령은 어느 것인지와 이유를 적으십시오.\n- 바꾼 파일, 실행한 명령과 실제 결과 줄, 작업이 요구한 증거(테스트 요약, 파일 목록, 스크린샷 경로), 끝내지 못한 것을 보고하십시오. 보고에 적는 개수와 주장은 diff와 일치해야 합니다.\n호출자 프롬프트의 언어로 간결하게 보고하십시오.\nMCP 도구나 목록에 없는 도구가 필요하면 즉시 멈추고 \"needs tools: <필요한 도구>\" 한 줄로 보고하십시오. 부모가 다시 위임합니다.\n확인하지 못한 내용은 추측하지 말고 확인하지 못했다고 말하십시오.\n전체 테스트, 빌드, 렌더처럼 프로세스를 여럿 띄우는 명령은 프로세스 상한을 걸고 실행하십시오. macOS 와 Linux 에서는 `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <명령>)` 으로 감싸고 Windows 에서는 그대로 실행합니다. 출력에 `spawn ... EAGAIN` 이나 `Resource temporarily unavailable` 이 보이면 테스트 실패가 아니라 프로세스 폭주이므로 명령을 다시 돌리지 말고 그 줄을 인용해 보고하십시오.",
|
|
114
|
+
"en": "Your role: multi-step work and the implementation half of a design the caller already fixed.\nDo only the delegated task, and stay within the tool-call cap and the scope the caller wrote in the prompt. An output-token cap governs lookups and reports. When the task is to change files, an output-token figure is an estimate and not a stop line: finish the specified changes and their tests.\nWhen the task changes files:\n- Before you change a function, a value or a format, search for its other callers and copies. Keep them working, or report the ones you left alone.\n- When a test enforces a list or a registry (environment variables, commands, exported names, mirrored files), add your new entry to it.\n- If the design does not fit the code, stop and report the conflict. Do not implement a different design.\n- Change only the files the task owns and leave nothing else behind: no symlinks, logs or temporary files in the working tree.\n- Before you report, run every command the task names (tests, demos, screenshots). When it names no test, find and run the tests that cover the files you changed. If you could not run a command, say which one and why.\n- Report the files you changed, the commands you ran with their actual result lines, every piece of evidence the task asks for (test summary, file list, screenshot paths), and what you did not finish. Every count and claim in the report must match the diff.\nReport concisely, in the language of the caller's prompt.\nIf you need an MCP tool or any tool not on your list, stop at once and report one line: \"needs tools: <tools needed>\". The parent will delegate again.\nDo not guess at anything you could not verify; say that you could not verify it.\nRun a command that starts many processes (a full test suite, a build, a render) under a process cap: on macOS and Linux wrap it as `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <command>)`, on Windows run it as is. If the output shows `spawn ... EAGAIN` or `Resource temporarily unavailable`, that is a process runaway, not a test failure: do not rerun the command; quote that line and report."
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
{
|
|
@@ -136,8 +136,8 @@
|
|
|
136
136
|
"en": "Heavy worker for Fable sessions: large implementation, debugging and refactoring handed over with a fixed design. It has no MCP tools."
|
|
137
137
|
},
|
|
138
138
|
"body": {
|
|
139
|
-
"ko": "맡은 역할: 호출자가 설계를 확정한 대규모 구현과 디버깅입니다. 설계 판단과 되돌릴 수 없는 작업은 호출자에게 넘기십시오.\n위임받은 작업만
|
|
140
|
-
"en": "Your role: large implementation and debugging work whose design the caller already fixed. Hand design judgement and irreversible actions back to the caller.\nDo only the delegated task, and stay within the
|
|
139
|
+
"ko": "맡은 역할: 호출자가 설계를 확정한 대규모 구현과 디버깅입니다. 설계 판단과 되돌릴 수 없는 작업은 호출자에게 넘기십시오.\n위임받은 작업만 하고 호출자가 프롬프트에 적은 도구 호출 상한과 범위를 지키십시오. 출력 토큰 상한은 조회와 보고에 적용됩니다. 파일을 고치는 작업에서 출력 토큰 수치는 추정치이며 중단선으로 쓰지 않습니다. 설계서에 적힌 변경과 테스트를 끝까지 마치십시오.\n파일을 고치는 작업에서는 아래를 지키십시오.\n- 함수나 값이나 형식을 바꾸기 전에 그것을 쓰는 다른 호출 지점과 사본을 검색하십시오. 함께 동작하게 고치거나 고치지 않고 둔 곳을 보고하십시오.\n- 테스트가 목록이나 등록부(환경 변수, 명령, 내보낸 이름, 사본 파일)를 강제하면 새 항목을 거기에 추가하십시오.\n- 설계가 코드와 맞지 않으면 멈추고 충돌을 보고하십시오. 다른 설계로 구현하지 마십시오.\n- 작업이 맡긴 파일만 고치고 작업 트리에 symlink, 로그, 임시 파일을 남기지 마십시오.\n- 보고하기 전에 작업이 적어 준 명령(테스트, 데모, 스크린샷)을 모두 실행하십시오. 테스트 명령이 없으면 고친 파일을 다루는 테스트를 찾아 실행하십시오. 실행하지 못한 명령은 어느 것인지와 이유를 적으십시오.\n- 바꾼 파일, 실행한 명령과 실제 결과 줄, 작업이 요구한 증거(테스트 요약, 파일 목록, 스크린샷 경로), 끝내지 못한 것을 보고하십시오. 보고에 적는 개수와 주장은 diff와 일치해야 합니다.\n호출자 프롬프트의 언어로 간결하게 보고하십시오.\nMCP 도구나 목록에 없는 도구가 필요하면 즉시 멈추고 \"needs tools: <필요한 도구>\" 한 줄로 보고하십시오. 부모가 다시 위임합니다.\n확인하지 못한 내용은 추측하지 말고 확인하지 못했다고 말하십시오.\n전체 테스트, 빌드, 렌더처럼 프로세스를 여럿 띄우는 명령은 프로세스 상한을 걸고 실행하십시오. macOS 와 Linux 에서는 `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <명령>)` 으로 감싸고 Windows 에서는 그대로 실행합니다. 출력에 `spawn ... EAGAIN` 이나 `Resource temporarily unavailable` 이 보이면 테스트 실패가 아니라 프로세스 폭주이므로 명령을 다시 돌리지 말고 그 줄을 인용해 보고하십시오.",
|
|
140
|
+
"en": "Your role: large implementation and debugging work whose design the caller already fixed. Hand design judgement and irreversible actions back to the caller.\nDo only the delegated task, and stay within the tool-call cap and the scope the caller wrote in the prompt. An output-token cap governs lookups and reports. When the task is to change files, an output-token figure is an estimate and not a stop line: finish the specified changes and their tests.\nWhen the task changes files:\n- Before you change a function, a value or a format, search for its other callers and copies. Keep them working, or report the ones you left alone.\n- When a test enforces a list or a registry (environment variables, commands, exported names, mirrored files), add your new entry to it.\n- If the design does not fit the code, stop and report the conflict. Do not implement a different design.\n- Change only the files the task owns and leave nothing else behind: no symlinks, logs or temporary files in the working tree.\n- Before you report, run every command the task names (tests, demos, screenshots). When it names no test, find and run the tests that cover the files you changed. If you could not run a command, say which one and why.\n- Report the files you changed, the commands you ran with their actual result lines, every piece of evidence the task asks for (test summary, file list, screenshot paths), and what you did not finish. Every count and claim in the report must match the diff.\nReport concisely, in the language of the caller's prompt.\nIf you need an MCP tool or any tool not on your list, stop at once and report one line: \"needs tools: <tools needed>\". The parent will delegate again.\nDo not guess at anything you could not verify; say that you could not verify it.\nRun a command that starts many processes (a full test suite, a build, a render) under a process cap: on macOS and Linux wrap it as `(ulimit -u $(( $(ps -u $(id -u) -o pid= | wc -l) + 150 )); <command>)`, on Windows run it as is. If the output shows `spawn ... EAGAIN` or `Resource temporarily unavailable`, that is a process runaway, not a test failure: do not rerun the command; quote that line and report."
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
]
|
|
@@ -4,12 +4,12 @@ You were spawned by a delegation call from another session. These six rules
|
|
|
4
4
|
keep your exploration finite and your output usable by the caller that spawned
|
|
5
5
|
you.
|
|
6
6
|
|
|
7
|
-
1. **Stop at the cap, report what you finished.** The cap
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
1. **Stop at the cap, report what you finished.** The cap line at the end of
|
|
8
|
+
this section says what the cap is. If you are about to exceed it, or a call
|
|
9
|
+
fails and retrying would put you over it, stop where you are and report only
|
|
10
|
+
the work you actually completed. The caller runs at a higher tier and can
|
|
11
|
+
pick up from a partial result; pushing past the cap spends tokens nobody
|
|
12
|
+
asked you to spend.
|
|
13
13
|
|
|
14
14
|
2. **Decide the output shape first, then only fill it.** Settle the form your
|
|
15
15
|
answer should take before you start writing, and answer exactly what was
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"id": "fix-777a15",
|
|
52
|
-
"ko": "여러 파일에 걸친 구현을 맡으면 → 설계와 스펙 확정은 메인 모델이 하고 코드 작성은 T1 에이전트(t1-worker)에
|
|
53
|
-
"en": "When an implementation spans several files → the main model settles the design and specification and delegates the code writing to a T1 agent (t1-worker), never T2. Write the delegation prompt
|
|
52
|
+
"ko": "여러 파일에 걸친 구현을 맡으면 → 설계와 스펙 확정은 메인 모델이 하고 코드 작성은 T1 에이전트(t1-worker)에 위임하며 T2에는 구현을 맡기지 않는다. 위임 프롬프트는 다른 문맥 없이 실행할 수 있는 설계서로 쓴다. 설계서에는 목표와 이유, 확정한 설계(인터페이스, 이름, 데이터 모양, 경계 사례의 동작), 수정할 파일과 건드리지 않을 범위, 함께 고칠 곳(바꾸는 함수나 값을 쓰는 다른 호출 지점, 사본, 문서), 따라야 할 저장소 규약(테스트가 강제하는 목록, 등록 절차, 문체 규칙), 검사할 수 있는 완료 기준, 대상 테스트와 전체 테스트 명령, 보고 형식, 권장 티어와 그 이유를 적는다. 함께 고칠 곳과 저장소 규약은 메인 모델이 위임 전에 직접 찾는다. 워커는 설계서에 없는 규약을 알지 못한다. 구현 위임에는 출력 토큰 상한을 적지 않고 범위를 수정할 파일과 완료 기준으로 정한다. 설계가 코드와 맞지 않으면 다른 설계로 구현하지 말고 멈춰서 보고하라고 적는다. 이미 읽은 파일의 약 50줄 이하 변경이나 의존 단계가 하나뿐인 짧은 구현, 그리고 위임 도구나 하위 티어를 쓸 수 없는 경우는 메인 모델이 직접 처리한다. 위임한 구현은 끝날 때까지 기다리고 같은 구현을 중복 실행하지 않으며 돌아온 diff와 테스트 결과를 메인 모델이 직접 검증한 뒤에 완료로 보고한다. 테스트 통과만으로 끝내지 않는다. 서버와 CLI 코드는 diff를 읽어 숨은 결합(테스트가 강제하는 목록, 다른 용도로 쓰이던 헬퍼의 재사용)을 확인하고 보고의 주장을 diff와 대조한다",
|
|
53
|
+
"en": "When an implementation spans several files → the main model settles the design and specification and delegates the code writing to a T1 agent (t1-worker), never T2. Write the delegation prompt as a specification that runs without other context: the goal and its reason, the settled design (interfaces, names, data shapes, edge-case behaviour), the files to change and what must stay untouched, what else must change with it (other callers of a changed function or value, copies, documents), the repository conventions that apply (lists a test enforces, registration steps, style rules), checkable completion criteria, the targeted and full test commands, the report format, and the recommended tier with a one-line reason. The main model finds the other callers and the conventions itself before delegating; the worker cannot know a convention the specification leaves out. State no output-token cap for an implementation: scope is the files to change and the completion criteria. Tell the worker to stop and report, not to implement a different design, when the design does not fit the code. Keep changes of roughly 50 lines or less in files already read, a single short dependency chain, or cases where the subagent tools or the lower tier are unavailable on the main model. Wait for the delegated work instead of duplicating it, and verify the returned diff and the actual test results before reporting completion. Passing tests are not enough: for server and CLI code read the diff for hidden couplings (a list a test enforces, a helper reused for a different purpose) and check the report's claims against the diff"
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"id": "fix-bec8e9",
|
package/src/agents.js
CHANGED
|
@@ -99,6 +99,22 @@ export function agentForRule(rule, { agents = agentDefinitions() } = {}) {
|
|
|
99
99
|
/** Model alias an agent (or a legacy agent name) is pinned to, or undefined. */
|
|
100
100
|
export const modelOf = (name) => AGENT_MODEL[Object.hasOwn(LEGACY_AGENT_NAMES, name) ? LEGACY_AGENT_NAMES[name] : name];
|
|
101
101
|
|
|
102
|
+
/** Subagent types that carry implementation work (no type means general-purpose). */
|
|
103
|
+
const IMPL_AGENTS = new Set(['t1-worker', 't1h-worker', 'general-purpose', 'claude']);
|
|
104
|
+
const IMPL_AGENT_RE = /(?:^|[:-])(?:builder|worker)$/;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* True when a delegation target can implement: no type (general-purpose), one
|
|
108
|
+
* of the known implementing agents, or a name that ends in builder or worker.
|
|
109
|
+
* Lives here, not in impl-follow.js, because delegation-guard.js needs it too
|
|
110
|
+
* and impl-follow.js already reaches delegation-guard.js through its imports.
|
|
111
|
+
*/
|
|
112
|
+
export function isImplementingAgent(type) {
|
|
113
|
+
const t = typeof type === 'string' ? type.trim() : '';
|
|
114
|
+
if (!t) return true;
|
|
115
|
+
return IMPL_AGENTS.has(t) || IMPL_AGENT_RE.test(t);
|
|
116
|
+
}
|
|
117
|
+
|
|
102
118
|
/** Agent a bare tier name stands for when that agent's file exists. */
|
|
103
119
|
const TIER_AGENT = { sonnet: 't1-worker', opus: 't1h-worker', haiku: 't2-explore' };
|
|
104
120
|
|
package/src/codex/delegation.js
CHANGED
|
@@ -318,8 +318,10 @@ export function codexImplementationHint({ model, provider, sessionId, cfg = load
|
|
|
318
318
|
from: model, to: target.model, provider, effort: target.effort ?? null }, { dir });
|
|
319
319
|
return `[Sprag implementation delegation] The user-approved implementation-split policy keeps design and specification on the main agent. `
|
|
320
320
|
+ `Delegate only the implementation of that completed design to model ${target.model}${target.effort ? `, reasoning_effort ${target.effort}` : ''}, with fork_turns "none".${asRole} `
|
|
321
|
-
+ 'Never delegate design judgement or irreversible actions. Give one child a self-contained specification, owned files,
|
|
322
|
-
+ '
|
|
321
|
+
+ 'Never delegate design judgement or irreversible actions. Give one child a self-contained specification: the goal and its reason, the settled design, owned files and what must stay untouched, other callers and copies that must change with it, the repository conventions that apply, checkable completion criteria, the targeted and full test commands, the report format, and the reason for this model choice. '
|
|
322
|
+
+ 'Find the other callers and the conventions yourself before delegating. State no output-token cap: scope is the owned files and the completion criteria. '
|
|
323
|
+
+ 'Tell the child to stop and report, not to implement a different design, when the design does not fit the code. '
|
|
324
|
+
+ 'Do not recursively delegate. '
|
|
323
325
|
+ WAIT_TEXT + `\nEnd the child task message with this route line only:\n<!-- sprag:codex:route id=${id} -->`;
|
|
324
326
|
}
|
|
325
327
|
|
package/src/delegation-guard.js
CHANGED
|
@@ -34,7 +34,7 @@ import { homedir } from 'node:os';
|
|
|
34
34
|
import { loadConfig, saveConfig } from './config.js';
|
|
35
35
|
import { recentToolPaths } from './session-paths.js';
|
|
36
36
|
import { routeCapsFor } from './route-caps.js';
|
|
37
|
-
import { modelOf } from './agents.js';
|
|
37
|
+
import { modelOf, isImplementingAgent } from './agents.js';
|
|
38
38
|
import { routingEnabled, delegationGrade, normalizeDelegationGrade } from './routing-switch.js';
|
|
39
39
|
import { isJudgementDelegation, SAVING_GRADE_KINDS } from './judgement-prompt.js';
|
|
40
40
|
import { recordGradeAction } from './grade-counts.js';
|
|
@@ -169,9 +169,19 @@ export async function buildAppendix(payload, { cfg = loadConfig(), home = homedi
|
|
|
169
169
|
// given "about 90 tool calls" stopped after 7 calls at the rule's cap
|
|
170
170
|
// (2026-11-07), because the bounds told it to obey the cap whatever the
|
|
171
171
|
// prompt said. The caller's number now replaces the default.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
//
|
|
173
|
+
// An implementation hand-off gets no output-token cap at all, and a matched
|
|
174
|
+
// route cap does not apply to it either. Those caps are calibrated on
|
|
175
|
+
// lookups. In a replay of ten real implementation hand-offs the workers
|
|
176
|
+
// wrote 13,000 to 39,000 output tokens, and the one held to 8,000 stopped
|
|
177
|
+
// before it wrote its tests. This is checked before the own-budget line, so
|
|
178
|
+
// a figure like "8,000 output tokens" inside the prompt is not a stop line
|
|
179
|
+
// either; a tool-call budget or a scope limit in the prompt still holds.
|
|
180
|
+
const capLine = isImplementationHandOff(payload?.tool_input)
|
|
181
|
+
? IMPLEMENTATION_CAP_LINE
|
|
182
|
+
: statesOwnBudget(prompt)
|
|
183
|
+
? 'Cap for this delegation: the budget stated in your prompt above. It replaces the default cap.'
|
|
184
|
+
: `Cap for this delegation: ${calls} tool calls, ${out.toLocaleString('en-US')} output tokens.`;
|
|
175
185
|
sections.push(['## Bounds and output shape', bounds, capLine].join('\n\n'));
|
|
176
186
|
}
|
|
177
187
|
|
|
@@ -377,6 +387,35 @@ export function statesOwnBudget(prompt) {
|
|
|
377
387
|
return /\bbudget\b[^\n]{0,40}\d|예산[^\n]{0,40}\d|\b\d+\s*tool calls?\b|도구 호출\s*\d+\s*회/i.test(prompt);
|
|
378
388
|
}
|
|
379
389
|
|
|
390
|
+
/** Prompt wording that reads as an implementation specification. */
|
|
391
|
+
const IMPLEMENTATION_SPEC_RE = /수정할 파일|구현(?!하지\s*(?:마|말))|\bimplement|files? to (?:change|edit|modify|touch)|owned files|\brefactor|리팩터|설계는[^\n]{0,12}확정|design is (?:fixed|settled|final)|as designed|테스트를?\s*(?:추가|작성)|add (?:a |the |new )?(?:regression )?tests?\b/i;
|
|
392
|
+
/**
|
|
393
|
+
* Prompt wording that declares the work read-only. Broad on purpose: a wrong
|
|
394
|
+
* "false" keeps today's cap, which is the safe direction.
|
|
395
|
+
*/
|
|
396
|
+
const READ_ONLY_RE = /읽기 전용|read[- ]only|research task|web research only|no code changes|do not (?:edit|modify|change) any|(?:코드|파일)[는를은을]?\s*(?:수정|변경)하지 (?:마|말)|조사만|수정 금지/i;
|
|
397
|
+
|
|
398
|
+
export const IMPLEMENTATION_CAP_LINE = 'Cap for this delegation: no output-token cap. This is an implementation hand-off, and the code you write to files is the work itself. A tool-call budget or a scope limit stated in your prompt still holds; an output-token figure there is an estimate, not a stop line. Stop and report when the completion criteria hold, when the same failure repeats twice, or when the design does not fit the code.';
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* True when a delegation hands implementation work to a target that can do it:
|
|
402
|
+
* not a haiku target, a subagent type that implements, and a prompt that reads
|
|
403
|
+
* as an implementation specification without declaring itself read-only.
|
|
404
|
+
*/
|
|
405
|
+
export function isImplementationHandOff(toolInput) {
|
|
406
|
+
try {
|
|
407
|
+
const agentName = String(toolInput?.subagent_type || '');
|
|
408
|
+
const modelHint = String(toolInput?.model || modelOf(agentName) || agentName);
|
|
409
|
+
if (/haiku/i.test(modelHint)) return false;
|
|
410
|
+
if (!isImplementingAgent(agentName)) return false;
|
|
411
|
+
const prompt = toolInput?.prompt;
|
|
412
|
+
if (typeof prompt !== 'string') return false;
|
|
413
|
+
return IMPLEMENTATION_SPEC_RE.test(prompt) && !READ_ONLY_RE.test(prompt);
|
|
414
|
+
} catch {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
380
419
|
/** Effort a sonnet delegation runs at when the call passed none. */
|
|
381
420
|
export const RAISED_EFFORT = 'high';
|
|
382
421
|
|
package/src/impl-follow.js
CHANGED
|
@@ -57,7 +57,7 @@ import { routingEnabled } from './routing-switch.js';
|
|
|
57
57
|
import { logEvent } from './route-follow.js';
|
|
58
58
|
import { sessionModelRank, looksLikeImplementation } from './route-inject.js';
|
|
59
59
|
import { worthDelegating } from './route-scan.js';
|
|
60
|
-
import { resolveAgentName } from './agents.js';
|
|
60
|
+
import { resolveAgentName, isImplementingAgent } from './agents.js';
|
|
61
61
|
import { debug } from './debug.js';
|
|
62
62
|
|
|
63
63
|
const SESSION_ID_RE = /^[A-Za-z0-9_-]{1,100}$/;
|
|
@@ -70,9 +70,6 @@ const DELEGATE_TOOLS = new Set(['Task', 'Agent', 'spawn_agent']);
|
|
|
70
70
|
const EDIT_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
|
|
71
71
|
const EXCLUDED_PREFIXES = ['/tmp/', '/private/tmp/', '/var/folders/', '/private/var/folders/'];
|
|
72
72
|
const DOC_EXT_RE = /\.(md|mdx|markdown|txt|rst|adoc)$/i;
|
|
73
|
-
/** Subagent types that carry implementation work (no type means general-purpose). */
|
|
74
|
-
const IMPL_AGENTS = new Set(['t1-worker', 't1h-worker', 'general-purpose', 'claude']);
|
|
75
|
-
const IMPL_AGENT_RE = /(?:^|[:-])(?:builder|worker)$/;
|
|
76
73
|
|
|
77
74
|
const baseDir = (dir) => dir || userDataDir();
|
|
78
75
|
|
|
@@ -110,9 +107,7 @@ export function excludedPath(file) {
|
|
|
110
107
|
/** True when this tool call hands implementation work to another agent. */
|
|
111
108
|
export function countsAsDelegation(tool, input) {
|
|
112
109
|
if (tool === 'spawn_agent') return true;
|
|
113
|
-
|
|
114
|
-
if (!type) return true;
|
|
115
|
-
return IMPL_AGENTS.has(type) || IMPL_AGENT_RE.test(type);
|
|
110
|
+
return isImplementingAgent(input?.subagent_type);
|
|
116
111
|
}
|
|
117
112
|
|
|
118
113
|
function readEdits(file) {
|
|
@@ -135,13 +130,14 @@ function nudgeText({ n, files, target, lang }) {
|
|
|
135
130
|
if (lang === 'ko') {
|
|
136
131
|
const list = more > 0 ? `${shown} 외 ${more}개` : shown;
|
|
137
132
|
return `✇ [sprag] 위임 없이 파일 ${n}개를 직접 고쳤습니다(${list}). `
|
|
138
|
-
+ `남은 구현이 여러 파일에 걸치면 구현 분업 조항대로 설계와 수정할 파일, 완료 기준, 테스트 명령을 정리해 ${target}에 넘기십시오. `
|
|
133
|
+
+ `남은 구현이 여러 파일에 걸치면 구현 분업 조항대로 설계와 수정할 파일, 함께 고칠 곳, 저장소 규약, 완료 기준, 테스트 명령을 설계서로 정리해 ${target}에 넘기십시오. `
|
|
134
|
+
+ '출력 토큰 상한은 적지 않습니다. '
|
|
139
135
|
+ '남은 변경이 이미 읽은 파일의 약 50줄 이하이거나 설계를 아직 정하지 못했다면 그 이유를 답변에 한 줄로 밝히고 계속하십시오. '
|
|
140
136
|
+ '이 안내는 다음 위임 전까지 다시 나가지 않습니다.';
|
|
141
137
|
}
|
|
142
138
|
const list = more > 0 ? `${shown} and ${more} more` : shown;
|
|
143
139
|
return `✇ [sprag] You have edited ${n} files yourself without delegating (${list}). `
|
|
144
|
-
+ 'If the remaining implementation spans several files, follow the implementation split: write
|
|
140
|
+
+ 'If the remaining implementation spans several files, follow the implementation split: write the specification (design, files to change, other callers and copies that change with them, repository conventions, completion criteria, test commands, and no output-token cap), '
|
|
145
141
|
+ `and hand it to ${target}. `
|
|
146
142
|
+ 'If what remains is roughly 50 lines in files already read, or the design is not settled yet, say so in one line in your reply and continue. '
|
|
147
143
|
+ 'This notice does not repeat until the next delegation.';
|
|
@@ -10,28 +10,66 @@ export function implementationDelegationRule(agent = 'claude', lang = 'en') {
|
|
|
10
10
|
'- **구현 분업**: 여러 파일을 고칠 때 설계와 스펙 확정은 메인 모델이 맡습니다.',
|
|
11
11
|
` 구현은 ${agent === 'codex' ? '현재 부모 모델과 프로바이더의 T1 모델' : targetKo}에 위임합니다.`,
|
|
12
12
|
' Claude는 sonnet을 쓰고, Codex는 명시적 T1 매핑을 우선하며 없으면 자동 해석한 T1을 씁니다.',
|
|
13
|
-
' 두 모델의 성능이 같다고 가정하지 않으며 haiku나 T2에 구현을 맡기지
|
|
14
|
-
'
|
|
15
|
-
'
|
|
13
|
+
' 두 모델의 성능이 같다고 가정하지 않으며 haiku나 T2에 구현을 맡기지 않습니다(실측: Haiku는 구현',
|
|
14
|
+
' 7건 중 2건에서 기존 테스트를 깨뜨린 채 끝냈습니다).',
|
|
15
|
+
' 위임 프롬프트는 다른 문맥 없이 실행할 수 있는 설계서로 쓰고 아래 항목을 담습니다.',
|
|
16
|
+
' 1. 목표와 이유',
|
|
17
|
+
' 2. 확정한 설계: 인터페이스, 이름, 데이터 모양, 경계 사례의 동작',
|
|
18
|
+
' 3. 수정할 파일, 건드리지 않을 범위, 그 밖의 제약',
|
|
19
|
+
' 4. 함께 고칠 곳: 바꾸는 함수나 값을 쓰는 다른 호출 지점, 사본, 문서',
|
|
20
|
+
' 5. 따라야 할 저장소 규약: 테스트가 강제하는 목록, 등록 절차, 문체 규칙',
|
|
21
|
+
' 6. 검사할 수 있는 문장으로 쓴 완료 기준',
|
|
22
|
+
' 7. 대상 테스트와 전체 테스트를 돌리는 명령',
|
|
23
|
+
' 8. 보고 형식: 바꾼 파일, 실행한 명령과 실제 결과, 하지 못한 것',
|
|
24
|
+
' 9. 권장 모델과 선택 이유',
|
|
25
|
+
' 4번과 5번은 메인 모델이 위임 전에 직접 찾아서 적습니다. 워커는 설계서에 없는 호출 지점과',
|
|
26
|
+
' 규약을 알지 못합니다(실측: 구현 10건 재생에서 부분 판정 6건 중 3건이 여기서 나왔습니다).',
|
|
27
|
+
' 구현 위임에는 출력 토큰 상한을 적지 않습니다. 조회 룰의 상한은 구현에 맞지 않습니다(실측: 구현',
|
|
28
|
+
' 10건의 출력은 13,000~39,000 토큰이었고 8,000 토큰 상한을 받은 워커는 테스트를 쓰기 전에',
|
|
29
|
+
' 멈췄습니다). 범위는 수정할 파일과 완료 기준으로 정합니다. 설계가 코드와 맞지 않으면 다른',
|
|
30
|
+
' 설계로 구현하지 말고 멈춰서 보고하라고 적습니다.',
|
|
16
31
|
' 이미 읽은 파일의 약 50줄 이하 변경이나 의존 단계가 하나인 짧은 구현은',
|
|
17
32
|
' 분업 비용을 고려해 메인 모델이 직접 처리합니다. Codex에서 T1을 해석하지 못하면',
|
|
18
33
|
' 메인이 이어받습니다. 위임이 꺼져 있거나 하위 모델 또는 위임 도구를 사용할 수',
|
|
19
34
|
' 없어도 메인이 처리하고 그 이유를 알립니다.',
|
|
20
35
|
' 메인 모델은 위임 완료를 기다리고 같은 구현을 중복 실행하지 않습니다.',
|
|
21
|
-
' 반환된 diff와 테스트 결과를 직접 검증한 뒤 완료로 보고합니다.',
|
|
36
|
+
' 반환된 diff와 테스트 결과를 직접 검증한 뒤 완료로 보고합니다. 테스트 통과만으로 끝내지 않습니다.',
|
|
37
|
+
' 서버와 CLI 코드는 diff를 읽어 숨은 결합(테스트가 강제하는 목록, 다른 용도로 쓰이던 헬퍼의',
|
|
38
|
+
' 재사용)을 확인하고 보고의 주장을 diff와 대조합니다(실측: 구현 17건에서 손봐야 했던 결과 7건 중',
|
|
39
|
+
' 5건은 테스트를 통과했습니다). 화면 코드는 그대로 쓸 수 있는 비율이 높았습니다(5건 중 4건).',
|
|
22
40
|
].join('\n');
|
|
23
41
|
return [
|
|
24
42
|
'- **Implementation split**: the main model fixes the design and specification,',
|
|
25
43
|
` then delegates multi-file implementation to ${target}.`,
|
|
26
44
|
' Claude uses sonnet; Codex uses its resolved T1, not a presumed Sonnet equivalent.',
|
|
27
|
-
' Never use haiku or T2 for implementation
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
45
|
+
' Never use haiku or T2 for implementation (measured: Haiku left existing tests broken in',
|
|
46
|
+
' 2 of 7 implementations).',
|
|
47
|
+
' Write the delegation prompt as a specification that runs without other context. It states:',
|
|
48
|
+
' 1. the goal and the reason for it',
|
|
49
|
+
' 2. the settled design: interfaces, names, data shapes, edge-case behaviour',
|
|
50
|
+
' 3. the files to change, what must stay untouched, and any other constraint',
|
|
51
|
+
' 4. what else must change with it: other callers of a changed function or value, copies, documents',
|
|
52
|
+
' 5. the repository conventions that apply: lists a test enforces, registration steps, style rules',
|
|
53
|
+
' 6. completion criteria written as checkable statements',
|
|
54
|
+
' 7. the commands for the targeted tests and for the full suite',
|
|
55
|
+
' 8. the report format: files changed, commands run with their actual results, what was not done',
|
|
56
|
+
' 9. the recommended model with a one-line reason',
|
|
57
|
+
' The main model finds items 4 and 5 itself before delegating: the worker cannot know a caller',
|
|
58
|
+
' or a convention the specification leaves out (measured: 3 of 6 partial results in a replay of',
|
|
59
|
+
' 10 implementations came from exactly that). State no output-token cap for an implementation:',
|
|
60
|
+
' a lookup rule\'s cap does not fit one (measured: the 10 implementations wrote 13,000 to 39,000',
|
|
61
|
+
' output tokens, and the worker held to 8,000 stopped before writing its tests). Scope is set by',
|
|
62
|
+
' the files and the completion criteria. Tell the worker to stop and report, not to implement a',
|
|
63
|
+
' different design, when the design does not fit the code.',
|
|
64
|
+
' Changes of roughly 50 lines or less in files already in context, or one short dependency chain,',
|
|
31
65
|
' stay on the main model. Codex also stays on the main model if T1 is unresolved.',
|
|
32
66
|
' If delegation is off, or the model or subagent tools are unavailable,',
|
|
33
67
|
' stay on the main model and say why.',
|
|
34
68
|
' Wait for the child instead of duplicating its implementation. The main model',
|
|
35
|
-
' verifies the diff and actual test results before reporting completion
|
|
69
|
+
' verifies the diff and actual test results before reporting completion, and does not stop',
|
|
70
|
+
' at passing tests. For server and CLI code it reads the diff for hidden couplings (a list a',
|
|
71
|
+
' test enforces, a helper reused for a different purpose) and checks the report\'s claims',
|
|
72
|
+
' against the diff (measured: of 7 results in 17 implementations that needed fixing, 5 passed',
|
|
73
|
+
' their tests). Screen code was usable as it came more often (4 of 5).',
|
|
36
74
|
].join('\n');
|
|
37
75
|
}
|