Skip to content

Robustness: cancel runs that time out, and accept large prompts over stdin #11

Description

@matt-wright-dev

Two problems found while using the library from a consumer project, with both agents.

Timed-out runs keep the agent running

When a Vitest test times out, or the worker is killed, the container keeps running until the agent finishes on its own. It keeps spending tokens and nothing on the test side can stop it: runDocker has no cancellation and containers are not named.

How we saw it: started a container through runDocker, dropped the promise after 3 seconds, exited the process. docker ps still showed it running. Stale workspaces from interrupted runs pile up in the tmp root for the same reason.

Suggested fix:

  • give every docker run a unique --name
  • accept an AbortSignal (or an agent({ timeoutMs }) option); on abort, docker rm -f the container and reject with a clear error
  • remove the workspace of an aborted run as well

Size: small to medium.

Prompts of 128 KB or more fail before the agent starts

The prompt is passed as a single docker run argument. Linux caps one argument at 128 KB, so a long prompt (a pasted file, a transcript) fails with argument list too long.

How we saw it: a 120 KB prompt works, 130 KB fails. Claude Code accepts the same 200 KB prompt on stdin and proceeds normally. Cursor's agent -p also reads stdin.

Suggested fix: pipe the prompt through docker run -i instead of argv, always or above a size threshold. This also keeps prompts out of ps output on the host.

Size: small.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions