Skip to content

agent: cap context resource errors before pushing them to coderd #40

Closed

Description

@ibetitsmike

One oversized resource error wedges an agent's context push until the agent restarts.

coderd rejects a whole PushContextState when any resource error is longer than maxContextErrorBytes (4096, coderd/agentapi/context.go:44). Two agent paths on main put unbounded user-controlled text into res.Error:

  • skill front matter: front-matter name %q does not match directory %q and skill name %q is not kebab-case in agent/agentcontext/resolve.go (around lines 639 and 644);
  • instruction-file symlink resolution errors (the error embeds the target path).

pushWithRetry then retries the rejected snapshot forever. W1's UAT on #38 (65edd5cecf) reproduced both: a SKILL.md with a 5000-character name, and an AGENTS.md symlink to a 4076-character path. Neither path is changed by #38; #38 already caps custom agent definition errors at 1024 bytes on a rune boundary.

Proposed fix: cap every resource error once, at the point where the agent builds the push request, using the same rune-safe truncation #38 uses, so no single path can exceed the coderd limit. Keep the per-path messages as they are.

Acceptance:

  • Unit test: a resource with an error over 4096 bytes is pushed with a truncated error and the push succeeds.
  • Negative control: without the cap, that test fails.
  • Remote UAT repeats the two reproductions above and shows 0 push failures.

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

Activity

  1. added
    bug
    pstack-parity
    followup
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfollowuppstack-parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions