镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

fix(acp): add BUZZ_ACP_AGENT_ARGS_JSON for lossless structured argument transport - #6654

Open
BradGroux wants to merge 5 commits into
block:mainfrom
BradGroux:fix/agent-args-shlex
Open

BradGroux wants to merge 5 commits into
block:mainfrom
BradGroux:fix/agent-args-shlex

Conversation

@BradGroux

@BradGroux BradGroux commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Introduce BUZZ_ACP_AGENT_ARGS_JSON as a structured argument transport while preserving the legacy comma-separated behavior. Reject conflicting non-default legacy and JSON input and validate JSON without heuristically shell-splitting existing structured arguments.

Desktop and Kubernetes use JSON whenever commas, empty arguments, or edge whitespace would be lost by legacy normalization. Desktop explicitly removes inherited JSON input when selecting the legacy path, preventing stale configuration from overriding the intended arguments. Existing reserved environment controls remain intact; no production dependency is added.

Closes #6017.

Verification

Rebased onto main at 2d289f720de0. All 1,070 ACP tests (three ignored), 158 Kubernetes backend tests, and 51 native environment tests pass. Strict root/native all-target Clippy, formatting, file-size, and diff checks pass. Native tests ran without system keyring integration. Packaged GUI, Windows process launch, and live Kubernetes deployment were not exercised.

@BradGroux

Copy link
Copy Markdown
Contributor Author

This is a replacement for #6041, which was accidentally closed when branches were force-pushed after a commit identity rewrite. Prior review comments and feedback are preserved on the old PR:

#6041

@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from d2e7caf to 62e7c26 Compare August 25, 2026 19:16
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 36 commits behind). All 4 commits applied cleanly. BUZZ_ACP_AGENT_ARGS still uses comma-delimited parsing with no lossless alternative on current main, so this change is still needed.

No review comments on this PR. CI will verify the build and test gate.

@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from 62e7c26 to 3d2a850 Compare August 29, 2026 16:15
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 2d289f720de0012fa36b5f6faa0e3bdd845ccfcf...52d0dd4292d155d63bd1e4b5803d46c3f54b1deb.
A new review must complete for this exact range. When manual authorization
is required, a user with write access must comment exactly
@buzz-security-review 52d0dd4292d155d63bd1e4b5803d46c3f54b1deb to authorize a new review.
Any previous review applies only to its recorded range.

@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 62 commits behind at f249710, now at 00e61ea). The branch applies cleanly with all tests passing.

Still-needed assessment: No upstream commits in the 62-commit window address the same issue. This PR remains needed.

Review requests: buzz-oss-team review request is active from the previous pass.

@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from 3d2a850 to c790e6f Compare September 2, 2026 17:30
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto current block:main (2af9773d6) — 38 new commits since the last rebase pass (Aug 29, 00e61eafa). Rebased cleanly with no conflicts.

Still needed: Checked all 38 new upstream commits for overlap with this PR's topic. None of the upstream changes address the issue this PR fixes. The PR remains relevant.

Verification:

  • Branch is 0 commits behind block:main, mergeable on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits

@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from c790e6f to bda6f80 Compare September 3, 2026 17:18
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review — 2026-09-03

Base commit: 752cbfc03 (latest main)
Mergeable: Yes
Conflicts: None — rebased cleanly.

Accuracy review: Comma-containing arguments still break the legacy BUZZ_ACP_AGENT_ARGS delimiter.
Continued relevance: Still needed.

@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from bda6f80 to dce466f Compare September 3, 2026 17:45
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase and review update — Sep 3, 2026

Rebased onto latest main (88687876f). No conflicts.

Accuracy review: Main does not have BUZZ_ACP_AGENT_ARGS_JSON, set_agent_args_env(), or the shlex crate integration. Agent arguments containing commas are still silently mangled by comma-delimited splitting. The PR's structured JSON transport and shared producer helper are still needed.

Mergeable status: Confirmed MERGEABLE on GitHub after force-push.

@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase pass — Sep 5, 2025

Rebased onto current upstream main (f038cbbb0). Main moved 62 commits since the Sep 2 rebase pass (2af9773d6).

Rebase result

Rebased cleanly onto current main. No conflicts.

Still-needed assessment

Checked all 62 new main commits for overlap with this PR's topic. None obsoleted:

Verification

  • PR confirmed MERGEABLE on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits
  • Review requests to buzz-oss-team still active from the Aug 24 recovery pass

@BradGroux

BradGroux commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Restoration note — Sep 16, 2026: The original text of this comment was accidentally overwritten when the Sep 16 rebase pass posted its follow-up with an edit flag instead of as a new comment. What follows is a faithful reconstruction from the session record; the byte-exact original remains in this comment's GitHub edit history (hover the edited marker on this comment).

Rebase pass — Sep 9, 2026

Rebased onto current upstream main (c045321a7). Main moved 8 commits since the Sep 5 rebase pass (f038cbbb0).

Rebase result

Rebased cleanly onto current main. No conflicts.

Still-needed assessment

Checked all 8 new main commits for overlap with this PR's topic. None obsoleted. #6189 (mesh-llm upgrade) changes Cargo.lock and mesh files — does not affect structured argument transport.

Verification

  • PR confirmed MERGEABLE on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits
  • Review requests to buzz-oss-team still active from the Aug 24 recovery pass

@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebase pass — Sep 16, 2026

Rebased onto current upstream main (213092074). Main moved 37 commits since the Sep 9 rebase pass (c045321a7).

Rebase result

Rebased cleanly onto current main. No conflicts.

Still-needed assessment

No main commit adds BUZZ_ACP_AGENT_ARGS_JSON; #7586 (point agents at buzz --help) and #7584 (command tree in --help) change help text, not argument transport.

Verification

  • PR confirmed MERGEABLE on GitHub
  • All commits authored as Brad Groux (3053586+BradGroux noreply)
  • DCO signoff preserved on all commits
  • buzz-oss-team review request still active

What was not done

No local test suites were run. The rebase only repositions commits; conflict resolutions carry the same logical changes forward (CI will verify builds).

@BradGroux BradGroux left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review refresh — 2026-10-02

Reviewed against current main 5a4b2d3d.

Verdict: Lossless JSON argument transport is still needed, but this branch requires correction.

Blocking finding: set_agent_args_env() does not remove an ambient BUZZ_ACP_AGENT_ARGS_JSON when the selected path uses legacy args. An inherited value can therefore override or conflict with newly selected legacy arguments. Explicitly clear the JSON variable on the legacy path and cover inherited-env precedence.

Rebase check: The branch conflicts in Cargo.lock and current Desktop env-var tests, with substantial ACP/runtime overlap. Current rustfmt also fails. Resolve, format, and run focused ACP/Desktop/Kubernetes env tests before publication.

No branch update was pushed in this pass because updating the PR head would trigger the repository's pull_request GitHub Actions workflows, which this workstream is not authorized to trigger.

BradGroux and others added 5 commits October 22, 2026 09:06
BUZZ_ACP_AGENT_ARGS uses clap's value_delimiter = ',' so a value like
"-m my-model --reasoning low" arrives as a single comma-delimited entry
containing spaces. The old normalize_agent_args passed it through as one
argv element, which the agent binary could not parse — every agent with
multi-flag args timed out at 60s with a misleading error.

Add a minimal shell_split() that handles single/double quotes, backslash
escapes, and whitespace delimiting. When a comma-delimited entry contains
a space, it is shell-split into separate argv elements. Entries without
spaces pass through unchanged, preserving the existing comma-delimited
behavior.

No new dependency added (shlex is only a transitive build-dep via
cc/cmake/aws-lc-sys). AGENTS.md says do not add production dependencies
without approval, so the splitter is implemented inline.

7 new tests: shell_split unit tests (space-separated, single-arg,
double-quoted, single-quoted, backslash escape, empty) plus
normalize_agent_args integration tests.

Closes block#6017

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: dm-builder <f01486f036641ccb52c11bb1e0ff2346ea89a8b4e3b49cd772249948f6fcbae6@digitalmeld.communities.buzz.xyz>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
The hand-written shell_split had three issues identified in review:
- Malformed shell syntax (unmatched quote, trailing backslash) was silently
  reinterpreted, removing the quote/backslash and launching with different
  argv than the operator supplied.
- Only literal space was treated as a delimiter; tabs and other whitespace
  were not split.
- The README still said arguments were comma-only.

Replace shell_split with shlex::split (already a transitive build-dependency
via cc). Malformed entries are now preserved as-is with a warning instead of
being mutated. All whitespace is detected. README documents both comma- and
space-separated forms and the quoting contract.

Addresses themiguelamador's review feedback.

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
…sport

ravarora2's review identified that shell-splitting every BUZZ_ACP_AGENT_ARGS
entry containing whitespace breaks backward compatibility with structured
argument producers. Desktop and the Kubernetes controller already hold agent
arguments as Vec<String>/lists, and an element containing whitespace may
intentionally be one argv element. Once the list crosses the comma-delimited
environment boundary, Buzz cannot reliably infer whether whitespace means one
argument containing spaces or several shell words.

The shlex approach also corrupted Windows paths (removing backslashes) and
silently dropped text after # comment syntax.

Replaced the heuristic with an explicit, lossless design:

- BUZZ_ACP_AGENT_ARGS_JSON: new canonical JSON array of strings, parsed
  strictly with serde_json. No shell splitting, no character reinterpretation.
  Preserves spaces, backslashes, quotes, and empty arguments exactly.
- BUZZ_ACP_AGENT_ARGS: legacy comma-delimited behavior, unchanged. Entries
  are preserved as-is without shell splitting.
- Selection: neither set → default; JSON only → strict parse; legacy only →
  unchanged; both set → startup error; invalid JSON → startup error.
- BUZZ_ACP_AGENT_ARGS_JSON added to Desktop reserved env keys (code-execution
  surface, same category as BUZZ_ACP_AGENT_ARGS).
- shlex dependency removed from buzz-acp.

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
ravarora2's review identified that the PR only added the JSON env var
parsing in buzz-acp but did not update the actual producer paths — Desktop
spawn, model probe, auth, and the Kubernetes backend still emit only the
legacy comma-delimited BUZZ_ACP_AGENT_ARGS. This means normal Desktop/K8s
configuration is not fixed; only manual env var users benefit.

Wire all four producer paths to use set_agent_args_env, which selects the
transport based on whether any argument contains a comma:

- No commas: legacy comma-delimited BUZZ_ACP_AGENT_ARGS (backward compatible)
- Any comma: JSON-serialized BUZZ_ACP_AGENT_ARGS_JSON + legacy set to
  default "acp" (which the harness treats as "not configured")

Added agent_args_env() as a testable decision function returning
(legacy_value, Option<json_value>), with 4 unit tests covering comma-safe,
empty, single-comma, and multi-comma cases.

Added a K8s test for the comma-in-arg JSON transport path and updated the
existing args test to verify JSON is absent for comma-safe args.

Updated buzz-acp README to document producer behavior.

Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Co-authored-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <brad@digitalmeld.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
@BradGroux
BradGroux force-pushed the fix/agent-args-shlex branch from c67c750 to 52d0dd4 Compare October 22, 2026 16:45
@BradGroux

Copy link
Copy Markdown
Contributor Author

Still needed on current main: the legacy transport cannot preserve commas, empty arguments, or edge whitespace. Rebased while retaining upstream reserved keys and launch-prefix handling. Expanded automatic JSON selection to cover every lossy legacy case and removed ambient JSON state when Desktop selects legacy transport. Removed the new production serialization panic/lossy fallback and updated regressions and docs.

Verification: 1,070 ACP tests passed (three ignored), 158 Kubernetes backend tests, 51 native environment tests, strict root/native all-target Clippy, formatting, file-size, and diff checks passed. Native tests ran without system keyring integration; packaged GUI, Windows launch, and live Kubernetes deployment remain unverified. Head: 52d0dd4292d1.

This branch has not been deployed

No deployments
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.

buzz-acp: BUZZ_ACP_AGENT_ARGS splits on commas, not spaces — space-separated flags become one argv entry and every agent times out at 60s

1 participant