Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Merge batch 11-03 bq: #2712 (#2724)

0xken15d4da59f4c3e5
diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.ts
index 3c5bd1dc4..3e78e0a1d 100644
--- a/backend/src/superTabs/commands.test.ts
+++ b/backend/src/superTabs/commands.test.ts
@@ -3901,6 +3901,32 @@ describe('lost work (liveness.ts)', () => {
return { f, lead, group, worker, other, as, task, limit }
}
+ // Task #2321 (Ken, 11-03): River stayed "limited" after its notice went, as only `alerting` cleared and `limitedUntil` waited
+ // for its time; the roster, routing and notices kept treating it as limited.
+ it('clears the limit mark when the limit notice goes', () => {
+ const { f, worker, as, limit } = lostFixture()
+ limit()
+ const marked = () => f.state.agents.find(a => a.id === worker)!
+ expect(marked().limitedUntil).toBe(new Date(3_600_000).toISOString())
+ f.run({ type: 'agent.alert', agentId: worker, alert: 'limit', active: false }, as(worker), { now: 2000 })
+ expect(marked()).toMatchObject({ limitedUntil: null, alerting: [] })
+ })
+
+ it('clears the limit mark when the agent reports its work, and not on posts its host sends as it, or anyone else\'s', () => {
+ const { f, lead, group, worker, other, as, task, limit } = lostFixture()
+ limit()
+ const marked = () => f.state.agents.find(a => a.id === worker)!
+ f.run({ type: 'message.send', conversationId: group, text: 'Still here.', replyTo: null, recipientIds: [] }, as(other))
+ f.run({ type: 'message.send', conversationId: group, text: 'Checking.', replyTo: null, recipientIds: [] }, as(lead))
+ // Its host posts as the agent too: a skill refresh only it reads, a stop it could not make (review of #2712, Important 2).
+ f.run({ type: 'message.send', conversationId: group, text: 'Your skills changed.', replyTo: null, recipientIds: [worker], agentOnly: true }, as(worker))
+ f.run({ type: 'message.send', conversationId: group, text: 'Could not stop worker on host.', replyTo: null, recipientIds: [lead] }, as(worker))
+ expect(marked().limitedUntil).toBe(new Date(3_600_000).toISOString())
+ f.run({ type: 'work.resume', conversationId: group, assignmentId: task().assignment!.id, lostAt: task().assignment!.lost!.at }, as(worker), { now: 3_600_000 })
+ f.run({ type: 'work.status', conversationId: group, assignmentId: task().assignment!.id, status: 'working', result: 'Going on.' }, as(worker), { now: 3_600_001 })
+ expect(marked()).toMatchObject({ limitedUntil: null, alerting: [] })
+ })
+
it('loses a worker\'s task once its host says the model kept failing (its ten-minute alert); an ended alert loses nothing', () => {
const { f, worker, as, task } = lostFixture()
const model = (active: boolean) => f.run({ type: 'agent.alert', agentId: worker, alert: 'model', active }, as(worker))
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index 5ad51a57f..5c457673f 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -18,7 +18,7 @@ import { askedInSchema, RULE_MESSAGE_MS, ruleSchema, ruleTextSchema } from './ru
import { MAX_ATTACHMENTS, type Attachment } from './attachments.js'
import { checkMentions, MAX_MENTIONS, namedIn, saysName, textTags, withTags, type MentionTarget } from './mentions.js'
import { answerDecision, askDecisions, checkAsker, decisionChoices, decisionQuestion, MAX_OPEN_DECISIONS, MAX_QUESTIONS, type DecisionTarget } from './decisions.js'
-import { leadOf, TERMINAL_KEYS, terminalAlert, terminalRequest, terminalResult, toLead, type TerminalRequest } from './terminal.js'
+import { leadOf, TERMINAL_KEYS, terminalAlert, terminalRequest, terminalResult, toLead, type TerminalRequest, workedAgain } from './terminal.js'
import { changesRequested, engineerAnswered, leadNoticeRows, loseTasks, recordTaskState, renewLease, renewOwnTask, restartQuietTime, revisionReady, toldEngineer, waitingForReview } from './liveness.js'
import { DELETED_SWARM_COMMANDS, isPersonalSwarm, notThere, SWARM_DELETE_GRACE_MS } from './deletion.js'
import { ABANDONED, askedModel, coordinatorCopy, failureNotice, failureRecipients, MACHINE_REMOVED } from './startFailure.js'
@@ -1392,6 +1392,9 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
if (group.leadId && group.leadId !== next && group.id === groupProject(state, group).leadConversationId) protectLead(state, group.leadId)
}
+ // An agent reporting its work is working: a usage-limit mark on it is stale (terminal.ts workedAgain). Not a post: its host
+ // posts as the agent too (a skill refresh, a stop it could not make), which says nothing of the agent's engine (review of #2712).
+ if (actor.kind === 'agent' && command.type === 'work.status') workedAgain(state, actor.agentId)
switch (command.type) {
case 'agent.screen':
case 'agent.input': {
diff --git a/backend/src/superTabs/terminal.ts b/backend/src/superTabs/terminal.ts
index 186c3ae5c..759249cdd 100644
--- a/backend/src/superTabs/terminal.ts
+++ b/backend/src/superTabs/terminal.ts
@@ -145,6 +145,15 @@ export function terminalResult(state: SuperTabState, actor: Actor, request: Term
error: command.ok ? null : command.error! }
}
+/** An agent that reports its work is not stopped at a usage limit: its mark goes, as when its notice does (task #2321). Its
+ * host may still be ending the episode; that end then changes nothing. */
+export function workedAgain(state: SuperTabState, agentId: string): void {
+ const target = state.agents.find(a => a.id === agentId)
+ if (!target?.limitedUntil && !target?.alerting?.includes('limit')) return
+ target.limitedUntil = null
+ target.alerting = target.alerting?.filter(a => a !== 'limit')
+}
+
/** One row per episode: a repeated observation adds nothing, and `active: false` ends the episode. No screen text goes in the row.
* It is delivered to the agent's project Lead, in the agent's group when the Lead is there, else by a second row in the Lead's chat. */
export function terminalAlert(state: SuperTabState, actor: Actor, sender: Author, id: string, now: number,
@@ -154,6 +163,8 @@ export function terminalAlert(state: SuperTabState, actor: Actor, sender: Author
const alerting = target.alerting ?? []
if (!command.active) {
target.alerting = alerting.filter(a => a !== command.alert)
+ // The notice is gone: so is the mark, whatever time it named (task #2321: River stayed "limited" after its notice went).
+ if (command.alert === 'limit') target.limitedUntil = null
return []
}
if (alerting.includes(command.alert)) return []
diff --git a/cli/src/superTabs/fixtures/screens/claude-limit-after-tool.txt b/cli/src/superTabs/fixtures/screens/claude-limit-after-tool.txt
new file mode 100644
index 000000000..e28c63fbd
--- /dev/null
+++ b/cli/src/superTabs/fixtures/screens/claude-limit-after-tool.txt
@@ -0,0 +1,11 @@
+⏺ Bash(npx vitest run src/superTabs)
+ ⎿ Test Files 35 passed (35)
+ Tests 893 passed (893)
+
+ ⎿ You've hit your session limit · resets 3pm (Asia/Saigon)
+ /upgrade to increase your usage limit.
+
+────────────────────────────────────────────────────────────────────────────────
+❯
+────────────────────────────────────────────────────────────────────────────────
+ ⏵⏵ bypass permissions on (shift+tab to cycle)
diff --git a/cli/src/superTabs/fixtures/screens/claude-printed-codex-limit.txt b/cli/src/superTabs/fixtures/screens/claude-printed-codex-limit.txt
new file mode 100644
index 000000000..38596b89b
--- /dev/null
+++ b/cli/src/superTabs/fixtures/screens/claude-printed-codex-limit.txt
@@ -0,0 +1,17 @@
+⏺ Let me look at Nico's terminal before I reassign it.
+
+⏺ Bash(harness super-tab --tab t1 screen nico)
+ ⎿ • Ran npx vitest run src/superTabs/terminal.spec.ts
+ └ Test Files 1 passed (1)
+
+ ■ You've hit your usage limit. Upgrade to Pro (https://chatgpt.com/explore/pro), visit
+ https://chatgpt.com/codex/settings/usage to purchase more credits or try again at 4:08 PM.
+
+ › Ask Codex to do anything
+
+⏺ Nico is out of quota until 4:08 PM; I'll give the task to Echo.
+
+────────────────────────────────────────────────────────────────────────────────
+❯
+────────────────────────────────────────────────────────────────────────────────
+ ⏵⏵ bypass permissions on (shift+tab to cycle)
diff --git a/cli/src/superTabs/fixtures/screens/claude-printed-limit-first-line.txt b/cli/src/superTabs/fixtures/screens/claude-printed-limit-first-line.txt
new file mode 100644
index 000000000..376204216
--- /dev/null
+++ b/cli/src/superTabs/fixtures/screens/claude-printed-limit-first-line.txt
@@ -0,0 +1,8 @@
+⏺ Bash(harness super-tab --tab t1 screen nico)
+ ⎿ ■ You've hit your usage limit. Try again at 4:08 PM.
+ › Ask Codex to do anything
+
+────────────────────────────────────────────────────────────────────────────────
+❯
+────────────────────────────────────────────────────────────────────────────────
+ ⏵⏵ bypass permissions on (shift+tab to cycle)
diff --git a/cli/src/superTabs/terminal.spec.ts b/cli/src/superTabs/terminal.spec.ts
index fe9817f7a..c5561e17e 100644
--- a/cli/src/superTabs/terminal.spec.ts
+++ b/cli/src/superTabs/terminal.spec.ts
@@ -447,11 +447,38 @@ describe('reading a usage limit off a screen', () => {
['claude-weekly-limit', { resetAt: new Date(2026, 9, 30, 9, 0).toISOString() }],
['claude-opus-limit', { resetAt: new Date(2026, 9, 30, 9, 0).toISOString() }],
['claude-fable-limit', {}],
+ // Mid-turn, its notice is a row of its own after a tool's output (review of #2712, Important 1).
+ ['claude-limit-after-tool', { resetAt: new Date(2026, 9, 23, 15, 0).toISOString() }],
['codex-usage-limit', { resetAt: new Date(2026, 9, 27, 15, 5).toISOString() }],
['codex-model-limit', { resetAt: new Date(2026, 9, 23, 16, 5).toISOString() }],
])('reads the %s screen', (name, limit) => {
expect(limitOf(fixture(name), now)).toEqual(limit)
})
+ // Task #2321 (Ken, 11-03): River was listed limited while it worked, as it had just printed another agent's screen,
+ // which showed Codex's limit line. Only the engine's own notice marks an agent limited, never text it prints.
+ it.each([
+ ['claude-printed-codex-limit', 'a screen Claude Code printed, the limit line further down its tool output'],
+ ['claude-printed-limit-first-line', 'the limit line first in its tool output, right above the prompt'],
+ ])('reads no limit off %s: %s', name => {
+ expect(limitOf(fixture(name), now)).toBeNull()
+ })
+ it('reads no limit off a log a tool printed, quoted or indented, near the prompt', () => {
+ expect(limitOf('⏺ Read(logs/codex.log)\n ⎿ Read 3 lines\n 5-hour limit reached ∙ resets 3pm\n\n❯ ', now)).toBeNull()
+ expect(limitOf('• Ran cat codex.log\n └ ■ You\'ve hit your usage limit. Try again at 4:05 PM.\n\n› ', now)).toBeNull()
+ // A Claude Code screen printed in a tool's output, its header scrolled off: its "⎿" rows sit deeper than the engine's own.
+ expect(limitOf(' └ Test Files 1 passed (1)\n ⎿ You\'ve hit your session limit · resets 3pm\n\n❯ ', now)).toBeNull()
+ expect(limitOf('⏺ Update(notes.md)\n ⎿ Added 1 line\n 1 + You\'ve hit your session limit · resets 3pm\n\n❯ ', now)).toBeNull()
+ })
+ it('still reads Claude Code\'s limit dialog', () => {
+ expect(limitOf([
+ '╭──────────────────────────────────────────────────────────╮',
+ '│ You\'ve hit your limit · resets 3pm (Asia/Saigon) │',
+ '│ │',
+ '│ ❯ 1. Stop and wait for limit to reset │',
+ '│ 2. Upgrade your plan │',
+ '╰──────────────────────────────────────────────────────────╯',
+ ].join('\n'), now)).toEqual({ resetAt: new Date(2026, 9, 23, 15, 0).toISOString() })
+ })
it('knows a limit without a reset time, and ignores the words in an agent\'s own prose or far above the prompt', () => {
expect(limitOf('⎿ API Error: Usage limit reached\n> ', now)).toEqual({})
expect(limitOf('I will add a check for when the usage limit reached message shows.\n> ', now)).toBeNull()
@@ -459,6 +486,8 @@ describe('reading a usage limit off a screen', () => {
expect(limitOf('> ', now)).toBeNull()
// A full context is not a usage limit; a workspace out of credits is one.
expect(limitOf(' ⎿ Context limit reached · /compact or /clear to continue\n> ', now)).toBeNull()
+ // A notice under Claude Code's reply whose start has scrolled off the screen is still its own.
+ expect(limitOf(' ⎿ You\'ve hit your session limit · resets 3pm\n\n❯ ', now)).toEqual({ resetAt: new Date(2026, 9, 23, 15, 0).toISOString() })
expect(limitOf('■ You\'ve reached your workspace credit limit\n› ', now)).toEqual({})
})
})
diff --git a/cli/src/superTabs/terminal.ts b/cli/src/superTabs/terminal.ts
index 952559167..3f3b81407 100644
--- a/cli/src/superTabs/terminal.ts
+++ b/cli/src/superTabs/terminal.ts
@@ -93,11 +93,33 @@ export function modelFailing(text: string): boolean {
return text.split('\n').slice(-LIMIT_NEAR_LINES).some(line => MODEL_LINE.test(line))
}
+/** Claude Code's tool call, whose output it draws under it: "⏺ Bash(…)", "⏺ Read(…)", "⏺ mcp__github__get_pr(…)". */
+const TOOL_CALL = /^⏺\s+[\w.-]+\(/
+
+/** Whether line [at] of [lines] is where an engine draws its own notice, not text the agent printed (Ken, 11-03: River
+ * was listed limited while working, as it had just printed another agent's screen showing Codex's limit line). An engine
+ * draws its notice at the margin: Claude Code's status line and the border of its limit dialog, Codex's "■" line. Or, in
+ * Claude Code, as a row of its own at its two-space " ⎿ ": under its reply ("⏺ All green." then the notice), or after
+ * a blank line, as it comes mid-turn after a tool's output (review of #2712). A tool's output starts right under its call
+ * ("⏺ Bash(…)", no blank line between), and the rest is indented deeper, as is any screen a tool printed. */
+function ownNotice(lines: string[], at: number): boolean {
+ const line = lines[at]!
+ if (/^\S/.test(line)) return true
+ if (!/^ {2}⎿\s/.test(line)) return false
+ for (let above = at - 1; above >= 0; above--) {
+ const before = lines[above]!
+ if (!before.trim()) return true
+ if (/^\S/.test(before)) return !TOOL_CALL.test(before)
+ }
+ return true
+}
+
/** A usage limit on screen, with when it resets if the screen says; null for none. */
export function limitOf(text: string, now: number): { resetAt?: string } | null {
const lines = text.split('\n')
- const tail = lines.slice(-LIMIT_NEAR_LINES)
- const at = tail.findIndex(line => LIMIT_LINE.test(line))
+ const from = Math.max(0, lines.length - LIMIT_NEAR_LINES)
+ const tail = lines.slice(from)
+ const at = tail.findIndex((line, i) => LIMIT_LINE.test(line) && ownNotice(lines, from + i))
if (at < 0) return null
const said = tail.slice(at, at + 3).join(' ')
const reset = resetOf(said, now)
diff --git a/docs/plans/2026-11-03-limited-only-own-notice-plan.md b/docs/plans/2026-11-03-limited-only-own-notice-plan.md
new file mode 100644
index 000000000..1da60a0c9
--- /dev/null
+++ b/docs/plans/2026-11-03-limited-only-own-notice-plan.md
@@ -0,0 +1,56 @@
+# An agent is limited only by its engine's own notice Implementation Plan
+
+> **Way of working:** by this project's instructions (Engineer role), not subagent-driven-development: each failing test committed before its code, the branch pushed after each task, one independent review of the pull request. There is no Execution Handoff.
+
+**Goal:** Text an agent prints (tool output, other terminals' screens, quoted logs) never marks it limited; the engine's own limit notice still does; the mark clears as soon as that notice goes or the agent works again.
+
+**Architecture:** The host's `limitOf` keeps its words but reads where they stand. Claude Code draws its notice at the margin, in its own dialog, or as the `⎿` line under its own reply. Codex draws its notice at the margin after `■`. Tool output, by contrast, sits under a tool call (`⏺ Bash(…)`) or indented beneath it. The backend clears `limitedUntil` with the `limit` alert when the episode ends, and when the agent posts or reports work.
+
+**Tech Stack:** TypeScript; Vitest in `cli/` and `backend/`.
+
+**Spec:** Task #2321 (Ken), from River listed "Idle · limited" on 11-03 after printing other agents' screens.
+
+## Global Constraints
+
+- PR body first line: Requested by [email protected] through Harness.
+- A test that fails without the fix for every named risk; red/green in a PR comment; the full Super Tab integration suite for the backend change.
+- Swarm code stays out of `cli/src/core`. Temp files only in `mktemp -d` folders.
+
+## Review Focus
+
+- A limit line as the first line of a tool's output (` ⎿ ■ You've hit …` under `⏺ Bash(`) is not the agent's.
+- A limit line further down a tool's output, indented, is not.
+- Claude Code's own notice under its reply (`⎿ You've hit your session limit …` under `⏺ All green.`), at the margin ("5-hour limit reached"), in its dialog, and "API Error: Usage limit reached" still are; so is Codex's `■ You've hit …`.
+- An ended `limit` episode clears `limitedUntil`; a lost task's resume, which reads its own time, still works.
+- An agent posting while marked limited clears the mark; anyone else's post doesn't.
+
+## Design
+
+- **Growth, concurrency, migration, audience, identity:** N/A because it reads the same screen and writes the same agent field.
+- **Read cost:** none added.
+- **Scale:** N/A because it is one more line check per read.
+- **Compatibility:** an older host keeps its old reading until updated; the backend side helps every host.
+- **Failure:** an engine drawing its notice a new way stops alerting until taught; the agent still works and posts as before.
+- **Platforms:** macOS, Linux and Windows hosts share this code.
+
+---
+
+### Task 1: The host reads only the engine's own notice
+
+**Files:** Modify `cli/src/superTabs/terminal.ts`; Test `cli/src/superTabs/terminal.spec.ts` (and a fixture screen).
+
+- [ ] **Step 1:** Failing tests: a Claude Code screen whose tool output shows Codex's limit line, first or further down, is not limited; Claude Code's own notices and Codex's still are.
+- [ ] **Step 2:** Run `npx vitest run src/superTabs/terminal.spec.ts`. Expected: FAIL.
+- [ ] **Step 3:** Implement in `limitOf`.
+- [ ] **Step 4:** Run it again. Expected: PASS. Coverage of the file stays as it was.
+- [ ] **Step 5:** Commit the test, then the code; push.
+
+### Task 2: The mark clears with its notice, or when the agent works
+
+**Files:** Modify `backend/src/superTabs/terminal.ts`, `backend/src/superTabs/commands.ts`; Test `backend/src/superTabs/commands.test.ts`.
+
+- [ ] **Step 1:** Failing tests: `active: false` for `limit` clears `limitedUntil`; the agent's own post or work status clears it; another's doesn't.
+- [ ] **Step 2:** Run `npm test -- src/superTabs/commands.test.ts`. Expected: FAIL.
+- [ ] **Step 3:** Implement.
+- [ ] **Step 4:** Run it again, then `npm run test:super-tabs`. Expected: PASS.
+- [ ] **Step 5:** Commit the test, then the code; push.