Skip to content

fix: large tool inputs break bash PTC replay and pending-call serialization - #48

Open
kenzaelk98 wants to merge 2 commits into
LibreChat-AI:mainfrom
kenzaelk98:fix/ptc-large-tool-input
Open

fix: large tool inputs break bash PTC replay and pending-call serialization#48
kenzaelk98 wants to merge 2 commits into
LibreChat-AI:mainfrom
kenzaelk98:fix/ptc-large-tool-input

Conversation

@kenzaelk98

Copy link
Copy Markdown

Bash PTC tools are meant to handle arbitrary-size input, but the preamble's
internal plumbing quietly assumes inputs stay well under the kernel's
ARG_MAX (~128KB) — which isn't a safe assumption for every PTC use case.

Problem

Three spots in the bash PTC preamble pass raw tool input to jq via
--argjson (a command-line argument), capped by ARG_MAX:

  • _ptc_call_tool's pending-call write hits this hard: jq fails outright
    and the script aborts with "Argument list too long."
  • _ptc_history_matches_by_signature / _ptc_history_entry_matches_current_call
    hit it silently instead — the error is swallowed, so a cached result never
    matches, and the call re-executes on every replay round rather than
    reusing it.

Fix

Read the input via stdin (pending-call write — stdin is free there) or
--slurpfile (the two matchers — stdin is already used for their primary
input) instead of argv, in all three spots.

Also makes tool_history's per-entry/aggregate byte caps in
replay-state.ts configurable via PTC_MAX_TOOL_RESULT_BYTES /
PTC_MAX_TOOL_HISTORY_TOTAL_BYTES (defaults unchanged), for deployments
whose tools return larger outputs.

Testing

  • New bash smoke test: oversized input replays from history on the second
    run instead of re-issuing.
  • bun run build / bun run test pass in service/.
  • Existing bash smoke suite (93 cases) + the new case all pass.

@CLAassistant

CLAassistant commented Aug 11, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kenzaelk98
kenzaelk98 force-pushed the fix/ptc-large-tool-input branch from bf21a61 to 6325b72 Compare August 11, 2026 15:12
@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6325b7270c

ℹ️ 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".

Comment thread service/src/preamble-bash.ts
Comment thread service/src/config.ts Outdated
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.

3 participants