Skip to content

fix: cap context push errors where the agent builds the wire request - #44

Merged
ibetitsmike merged 11 commits into
mainfrom
mike/agentcontext-cap-push-errors
Nov 9, 2026
Merged

ibetitsmike merged 11 commits into
mainfrom
mike/agentcontext-cap-push-errors

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

One oversized context error no longer blocks an agent's context sync until the agent restarts.

coderd rejects a whole PushContextState when any resource or snapshot error is over 4096 bytes (maxContextErrorBytes), and the agent keeps retrying the rejected push. Skill front-matter errors (skill name %q is not kebab-case, front-matter name %q does not match directory %q) and instruction-file symlink errors quote unbounded user text, so a single SKILL.md with a 5000-character name or an AGENTS.md symlink to a long path stopped every resource from syncing.

  • pushRequestToProto now truncates each resource error and the snapshot error to 1024 bytes on a UTF-8 rune boundary, with a (truncated) suffix (agent/agentcontext/fork_push.go). The local resolver output and per-path messages are unchanged.
  • That single cap replaces the definition-only cap feat: discover custom agent definitions and persist them as subagent context resources #38 added in fork_agents.go.
  • TestPushContextStateAcceptsAgentOversizedErrors drives the agent's DRPCPusher into coderd's real ContextAPI.PushContextState. Removing either truncation makes coderd reject the push (error is 5031 bytes, exceeds 4096 byte cap), so the test catches the agent and server caps drifting apart.

Fixes #40. Part of #7.

Xum opened this PR on behalf of @ibetitsmike.

…ted MCP servers

Claude Code names the reasoning level `effort`; accept it, with
`reasoning_effort` taking precedence. Claude Code's `mcpServers` adds servers
to the inherited set instead of restricting it, so it no longer switches the
definition to a named allowlist.
coderd rejects a whole PushContextState request when any resource error
exceeds 4096 bytes. A definition with many unknown front-matter fields,
or a long invalid name quoted in the parse error, produced an unbounded
error and stopped every context resource from syncing. Truncate agent
definition errors to 1024 bytes on a rune boundary.
- Skip agent containers that resolve outside their scan root, since
  definitions are shipped whole.
- Watch the existing parent of a missing container (such as .claude) so
  creating the container later is picked up.
- Skip a definition whose source is already a resource (an AGENTS.md in
  an agents scan root); coderd rejects pushes with duplicate sources.
- Reject inline mcpServers definitions, which often carry credentials,
  instead of shipping them with a warning.
coderd rejects a whole PushContextState when any resource or snapshot
error exceeds 4096 bytes, and the agent retries that push forever. Skill
name errors and symlink resolution errors quote unbounded user text, so
one bad SKILL.md or AGENTS.md symlink stopped all context sync.

Truncate every error to 1024 bytes on a rune boundary in
pushRequestToProto, replacing the definition-only cap from the agent
discovery change. The test drives the agent's pusher into coderd's real
handler so it fails if the two caps drift apart.

Fixes #40
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T10:35:55.712561Z 0bb4054 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 0bb40544e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Base automatically changed from mike/custom-agent-types-2-discovery to main November 9, 2026 11:31
…-push-errors

# Conflicts:
#	agent/agentcontext/fork_agents.go
#	agent/agentcontext/fork_agents_test.go
#	coderd/agentapi/fork_context_test.go
@ibetitsmike
ibetitsmike merged commit 9a63b6a into main Nov 9, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/agentcontext-cap-push-errors branch November 9, 2026 12:32
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike.

Merge evidence at head a5dc0bd746:

  • fork-ci pull_request run 42609944272 green on this head (all checks pass), MERGEABLE/CLEAN, 0 unresolved review threads.
  • Codex receipt clean on 0bb40544e8. The only later change is a merge of main; git diff origin/main...a5dc0bd746 is byte-identical to the reviewed patch (9d557af4af..0bb40544e8), so the receipt and remote UAT round 4 PASS on 0bb40544e8 stand.
  • Merged after the previous main commit e12a13e3c6 deployed healthy locally (buildinfo, migrations 640 clean, no new-process errors). Closes agent: cap context resource errors before pushing them to coderd #40.

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.

agent: cap context resource errors before pushing them to coderd

1 participant