Repository navigation
sync: label the agent's Claude runs autofork, so the 5-hour limit meters them like interactive Claude Code - #18
Conversation
…ers them like interactive Claude Code
microscope reviewed
|
| Check | Result |
|---|---|
| Correctness | No issues new, 1 open, 0 code objects reviewed |
| Architecture, Standards, and Engineering Philosophy | No violations: the entrypoint label is added in one place with no new dependencies |
| Approvability | Needs human approval |
Approvability: The code change is small and works. If env is undefined, {...(env ?? process.env)} gives the same result as before. Tests cover both the inherited-label case and the case where the user sets their own label. Two things still need a person. First, the PR exists to change how Anthropic's 5-hour usage limit counts autofork's Claude runs. It sets CLAUDE_CODE_ENTRYPOINT=autofork on purpose so claude -p runs are counted at the interactive rate instead of the sdk-cli rate. Whether it's acceptable to relabel requests to get more usage under the limit is a policy and terms-of-service call that a human should make. Second, there's an unresolved review finding: when autofork runs inside a Claude Code session (CLAUDECODE set), a label the user deliberately set is silently replaced with autofork, and neither the code comment nor the README says so. The label also goes to custom agent commands, which changes what every user-supplied agent sees in its environment.
Resolved since the last review:
test/autofork.test.ts:2349
Architecture, Standards, and Engineering Philosophy
I checked the diff against each standard and found nothing to flag.
- Service boundaries and dependency direction: The diff adds no imports and doesn't reach into any other module. All of it is inside
src/autofork.ts. - Public API: No exported types or request/response shapes change. The only signature involved,
agent(), stays the same. When noenvis passed,env ?? process.envkeeps the old behavior of using the current environment. The callers that passBOT(lines 818 and 1151) still get exactly that environment, now with one extra variable. - Simplicity: It's a one-line module-level constant plus a one-line spread at the only place the engine starts Claude, with no extra layers of indirection. A comment explains why an inherited
CLAUDE_CODE_ENTRYPOINTis replaced whenCLAUDECODEis set, and two tests cover the override cases. - Tech stack: No new packages.
Claude Code labels
claude -prequestssdk-cli, and Claude's 5-hour limit drains faster for that label than for interactive Claude Code: about 1.6x to 1.7x in Theo's A/B on one Max account (pingdotgg/t3code#24649), 1.8x to 2.9x in anthropics/claude-code#97074. The weekly limit isn't affected. T3 Code fixed it for its own sessions in pingdotgg/t3code#28410 by settingCLAUDE_CODE_ENTRYPOINT=t3-code; a check after that merge on a Pro plan found a session labeledt3-code, started withclaude -p, drained at the interactive rate (0.92x to 0.96x, ±20% from the whole-percent meter).Change
agent()starts the agent withCLAUDE_CODE_ENTRYPOINT=autofork. That's the one place the engine starts Claude: patch rebuilds, verify fixes and workflow updates all go through it, andaction.shonly runs the engine.CLAUDE_CODE_ENTRYPOINTthe user set wins. One inherited from a Claude Code session autofork runs inside (CLAUDECODEis set there, with that session's own label, likesdk-cli) is replaced, as T3 Code does with an inherited host value.agentcommand too, so a custom command that runs Claude gets the same label.Unlike T3 Code, this doesn't read the label from Claude's
settings.jsonenv: Claude Code 2.1.316 ignores it there, and forks run in Actions with no settings file.Verification
The billed-run test checks that the stub
claudeseesCLAUDE_CODE_ENTRYPOINT=autofork, andminewhen the user setmineoutside a Claude Code session.bun run checkpasses.Note
Label the agent's Claude runs
autoforkso the 5-hour limit meters them at the interactive ratesrc/autofork.ts:agent()now starts the agent withCLAUDE_CODE_ENTRYPOINT=autofork. Claude's 5-hour limit drains faster for runs labeledsdk-cli(the labelclaude -pgets). This applies to customagentcommands too.CLAUDE_CODE_ENTRYPOINT, it's kept. The exception is whenCLAUDECODEis set: then the value came from the surrounding Claude Code session and gets replaced.dist/autofork.js: the built bundle, rebuilt with the same change.test/autofork.test.ts: the billed-run test now checks that an inheritedsdk-clibecomesautofork, and thatmineis kept when it's set outside a Claude Code session.env ?? process.envgives the same environment as before when noenvis passed. The label is read once, when the module loads.🔬 microscope summarized 0bc9ba4. 0 files reviewed, 0 issues evaluated, 0 filtered, 0 comments posted
Note
Set
CLAUDE_CODE_ENTRYPOINTtoautoforkfor agent-spawned Claude runsLabels the agent's Claude runs as
autoforkso the 5-hour limit meters them like interactive Claude Code. A new selector in autofork.ts picks the label: it usesCLAUDE_CODE_ENTRYPOINTwhenCLAUDECODEis unset or empty, otherwise it defaults toautofork. The agent process launcher then setsCLAUDE_CODE_ENTRYPOINTon the spawned environment, overriding any inherited value.Tests in autofork.test.ts cover both paths: an inherited
sdk-clilabel inside a Claude Code session becomesautofork, and an inheritedminelabel is kept whenCLAUDECODEis empty. autofork.js is the regenerated bundle.Behavioral Change: the spawned agent's
CLAUDE_CODE_ENTRYPOINTvalue is now always overwritten with the selected label.Macroscope summarized 0bc9ba4.