Skip to content

[agentbricks] Honor --output json in sessions unbind - #923

Open
shivam5 wants to merge 1 commit into
mainfrom
agentbricks/sessions-unbind-json
Open

shivam5 wants to merge 1 commit into
mainfrom
agentbricks/sessions-unbind-json

Conversation

@shivam5

@shivam5 shivam5 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

agentbricks --output json sessions unbind ignored the selected output mode. If a binding was removed, it printed the Rich success panel. If none was bound, it printed No session store binding in …/agent.toml.. Either way, stdout was not JSON, and both cases exited 0, so a script couldn't tell them apart.

With --output json (before or after the subcommand), sessions unbind now prints exactly one JSON object in both cases:

{"session_store": null, "removed": true, "manifest": "/path/to/agent.toml"}
{"session_store": null, "removed": false, "manifest": "/path/to/agent.toml"}

This follows the removed flag that models unbind and prompts unbind already return. The default text output is unchanged. agent.toml is still rewritten only when a binding is actually removed, and other tables ([agent], [memory_store], [tracing]) are left untouched.

Validation

  • The installed CLI was run from this commit on a freshly scaffolded project. sessions bind, then --output json sessions unbind twice (bound, then unbound, including -o json after the subcommand), then the same in text mode. Every command exited 0, and each JSON stdout parsed as a single object with removed: true and then removed: false. Text mode still shows the "Removed session store binding" panel with its redeploy next step, and still prints the "No session store binding" line. Apart from [session_store], agent.toml was identical to the starting file after every step. Before this change, both JSON unbind calls failed to parse (Expecting value).
  • New tests in tests/unit_tests/bind_cli_test.py cover JSON removal with an unrelated memory binding preserved, JSON when nothing is bound (manifest unchanged), and unchanged text output. The two JSON tests fail without the fix. All 10 tests in the file pass with it. I checked formatting by hand against the 100-column limit; CI runs Ruff, ty and the full suite.

No cli.md or agent-bricks-workflow skill update: the command's options and help text are unchanged, and the skill already says to use --output json for programmatic use.

memory unbind has the same issue and is left for a separate change.

Rollback: revert this commit.

🤖 Generated with Claude Code

`agentbricks --output json sessions unbind` printed the human success panel
(binding removed) or a "No session store binding" line (nothing bound),
so stdout was never valid JSON. Emit one JSON object in both cases:
{"session_store": null, "removed": <bool>, "manifest": "<agent.toml path>"}.
Default text output is unchanged; agent.toml is only rewritten when a
binding was actually removed.

Adds regression tests for JSON removal (with an unrelated memory binding
preserved), JSON with no binding (manifest unchanged), and unchanged text.

No cli.md or agent-bricks-workflow skill update: the command's options and
help text are unchanged, and the skill already directs `--output json`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

AgentBricksReviewer

Review score: 100/100 · reviewers: 2/2 · Change risk: MODERATE · risk:medium

Summary

No findings.

Approach: The approach is sound and follows existing JSON-output patterns. More in Details.

Risk

Changes public CLI stdout consumed by scripts. The change is isolated to JSON-mode success output; text output and existing manifest-write behavior remain unchanged. Focused regression tests cover removal and no-op cases, but were inspected rather than executed. Reverting restores the prior behavior without a state migration.

AI approval

Review checks passed (ai-approved), and the PR is eligible for auto-approval. github-actions[bot] approves it if the author has write access, the PR isn't a draft, and the reviewed commit is still the head.

Details

Approach: The approach is sound and follows existing JSON-output patterns. It reuses the project mutation and rendering helpers, emits JSON after any required write succeeds, and returns before text rendering. No additional abstraction is warranted.

Review rules: REVIEW.md, integrations/agentbricks/REVIEW.md at e50cab552e74baf87d6cbc4a77bb9e51f50828fa · checked: BRIDGE-001–010, AGENTBRICKS-001–003 for applicability; relevant checks satisfied · gaps: none in rule coverage; execution limitation below.

Diff size (computed): 2 files; +57 / -1 lines (58 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 1 51 0 87.9%
Documentation 0 0 0 0.0%
Dependencies and lockfiles 0 0 0 0.0%
Implementation / other 1 6 1 12.1%

Changes

The implementation makes sessions unbind honor JSON output for both removed and already-unbound cases. Three regression tests cover the new output and unchanged text behavior. The small implementation change and focused tests are justified; no concrete reduction is needed.

No CLI definitions or help strings change. Existing bundled guidance already recommends JSON for programmatic consumption, so documentation changes are unnecessary.

Tests

Test-by-test assessment
Test / case Behavior protected Layer Needed? Action / rationale
integrations/agentbricks/tests/unit_tests/bind_cli_test.py Exact JSON payloads for removal and no-op; unrelated memory binding preserved; unchanged manifest bytes on no-op; retained text messages CLI unit tests with temporary project files keep Focused regression coverage; both JSON tests detect the original bug by parsing the complete captured output.

Tests, lint, and typechecking were not run during review: the environment lacked pytest, the installed package, and a package-local virtual environment. The author's reported passes were not independently verified.

The tests adequately cover the handler change by inspection. Root-CLI cases for output-option placement would strengthen end-to-end coverage; a write spy would directly prove that no-op unbinding does not rewrite the manifest.

Scope

All changes support the stated JSON-output fix. No unrelated changes were found. Leaving memory unbind for a separate change is appropriate.


Automated review by AgentBricksReviewer for 20807f7 · workflow run · comment /review to re-run

@github-actions github-actions Bot added ai-approved Passed AI findings and coverage checks; not a GitHub approval risk:medium Change risk assessed by AgentBricksReviewer: medium labels Nov 17, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto-approved by AgentBricksReviewer for 20807f7: change risk medium (advisory; see the review comment for rationale), review score at least 95, every reviewer delivered, no blocking, security, or uncertain findings, at most 500 changed lines, and no CI, dependency, or credential files. Pushing new commits dismisses this approval. Workflow run

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

ai-approved Passed AI findings and coverage checks; not a GitHub approval risk:medium Change risk assessed by AgentBricksReviewer: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant