Skip to content

fix(channels): keep group GitHub reads working after a rate-limited connection - #1394

Merged
zhaozhaozz merged 1 commit into
agent-CI-Infra:mainfrom
zhaozhaozz:fix/issue-1393-group-github-reader
Nov 26, 2026
Merged

zhaozhaozz merged 1 commit into
agent-CI-Infra:mainfrom
zhaozhaozz:fix/issue-1393-group-github-reader

Conversation

@zhaozhaozz

Copy link
Copy Markdown
Collaborator

Fixes #1393

Problem

In a group assistant turn, the first GitHub read that hits a rate limit breaks every later read in that turn. In production (DM开发群 daily report, 2026-11-26 01:00–01:15 UTC), the first github_search was refused because the openJiuwen-ai installation's window was used up until 01:10. The next 11 github_read / github_search calls all returned github_read_token_required, including the calls made after the reset. The report then asked an administrator to restore the bot's read credential, but the installation was healthy.

Cause

github() in src/channels/service-session.ts registered the per-repository reader in explorers first and only then connected it with execute('github_read_token', {}). RepositoryExplorer.execute rethrows github_rate_limited, so entry.error was never set and the explorer kept no client. Every later call reached !this.client and answered github_read_token_required. Nothing connected again, and the group tool set has no github_read_token tool, so the model could not recover either.

src/service-roles/resources.ts (the assistants' repository tools) connected before every call, so it was not sticky. A rate limit still left it as a thrown TaskError, though. The task-tool dispatcher (src/roles/task-tools.ts) hands only HttpError refusals back to the model, and the management assistant sets no repairInvalid. So on Pi this error propagated out of the tool call instead of reaching the model as an observation.

Fix

New RepositoryExplorer.executeConnected(name, args) in src/agent/exploration.ts, used only by the two sessions that offer no github_read_token tool (group turns and ServiceRepositories):

  • It connects before every call. A failed connection leaves no half-connected reader, and the next call connects again.
  • A rate limit, whether on the connection or on the read itself, is returned as an observation instead of thrown:
    • error: 'github_rate_limited';
    • bucket, for example installation:175700149;
    • reset_at, or null when GitHub gave no time;
    • the client's detail;
    • an instruction saying that the credentials and permissions are fine and that the model should retry after reset_at.
  • While a rate-limited connection's window is still used up, calls get the same answer without minting another token. Without this, each call in the window would mint a token that runs straight into the window. Each mint also counts against ReadTokens.maxIssued (10). The production turn made 11 calls, so it would have ended with github_read_token_limit, which is again sticky and misleading.

The task path stays as it is. execute() still rethrows github_rate_limited, so a task attempt waits for the reset. github_read_token is still an explicit tool for tasks, and reads without it still answer github_read_token_required. The new ST asserts the rethrow.

docs/design/agent-and-harness-runtime.md describes the two contracts.

Side effect: in groups, a connection failure that is not a rate limit (for example github_unavailable) is no longer cached for the rest of the turn. The next call tries again, as the assistant path already did.

Tests

  • test/st/src/channels/channel-service-bindings.test.mjs, a new group turn case. The installation window is used up for about 1.5 s. Then:

    1. github_read returns github_rate_limited with the bucket, reset_at and the instruction.
    2. github_search in the same window gets the same answer and no new token.
    3. After reset_at, github_read returns the PRs.

    No observation in the turn contains github_read_token_required. Two tokens are minted (the refused connection and the one after the reset), and both are revoked.

  • On main's service-session.ts the same case fails: calls 2 and 3 return { repository, result: { error: 'github_read_token_required' } }.

  • test/st/src/agent/repository-exploration.test.mjs, the same sequence through ServiceRepositories (assistant tools). It also checks that the task-side execute('github_read_token') still rejects with github_rate_limited.

Verification

Head 6a5ca1d5 (on main 52980755), Node 22.19.0:

  • npm ci exit 0; (cd runner && npm ci) exit 0.
  • npm run check exit 0.
  • npm test exit 1: 2844 tests, 2836 passed, 8 failed in 3 sets that this change does not touch. Each one passes when it runs alone:
    • distributed-nodes: node_agent_connect_timeout under parallel load. Passes alone: node test/framework/test-sets.mjs --jobs 1 test/st/src/cluster/distributed-nodes.test.mjs.
    • codex-harness: two "stopped promptly" timing assertions under parallel load. Passes alone with the same command.
    • runner-transport: EADDRINUSE on Unix sockets. Under this worktree the socket paths are 147 characters, above the 108-byte sun_path limit. It fails alone too, for the same reason. With a short TMPDIR it passes: TMPDIR=<worktree>/.tmp/s node --test test/ut/manager/runner-transport.test.mjs gives 4/4.
  • The new tests pass in the full run (sets repository-exploration and channel-service-bindings).

…onnection

A group turn registered its per-repository reader before connecting it. When
the first connection hit GitHub's rate limit, RepositoryExplorer rethrew it,
so the reader stayed without a client and every later read in the turn
answered github_read_token_required, even after the window reset. The group
tool set has no github_read_token tool, so the model could not recover and
reported the bot's credentials as broken.

Group and assistant repository tools now go through
RepositoryExplorer.executeConnected: it connects before every call, answers a
rate limit as an observation with the bucket, the reset time and a statement
that credentials and permissions are fine, and mints no token while a refused
connection's window is still used up (each mint would count against the
read-token limit). Task-side execute and github_read_token keep their contract.

Fixes agent-CI-Infra#1393
@zhaozhaozz
zhaozhaozz added this pull request to the merge queue Nov 26, 2026
@zhaozhaozz

Copy link
Copy Markdown
Collaborator Author

Reviewed head 6a5ca1d557833d6bdc98e4dacf5debcde8a0fa98. No blocking issues: executeConnected connects before each call, keeps a rate-limited connection from leaving a half-connected reader, answers github_rate_limited as an observation (bucket, reset_at, credentials-are-fine instruction) and does not mint a token while the window is used up; the task path still rethrows. Required checks (unit, e2e, four image builds) pass and CodeQL is clean. Both new ST cases fail against main's sources and pass here. Enqueued for merge at this head.

Merged via the queue into agent-CI-Infra:main with commit 2181608 Nov 26, 2026
12 checks passed
@zhaozhaozz
zhaozhaozz deleted the fix/issue-1393-group-github-reader branch November 26, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Group assistant: one rate-limited GitHub read breaks every later read in the turn

1 participant