Skip to content

fix: honor quiet mode when setting budgets - #191

Merged
yunaremaia merged 1 commit into
yunaremaia:mainfrom
haoxuanjng-lang:fix/budget-set-quiet
Oct 3, 2026
Merged

yunaremaia merged 1 commit into
yunaremaia:mainfrom
haoxuanjng-lang:fix/budget-set-quiet

Conversation

@haoxuanjng-lang

@haoxuanjng-lang haoxuanjng-lang commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

agentcost budget set --daily 5 --quiet still prints Daily: $5.00, even though the flag promises exit-code-only output. Move the daily, weekly, and monthly messages into the existing quiet guard so successful quiet invocations produce no console output.

The regression test covers daily-only and combined thresholds with both --quiet and -q. It also checks normal output, successful exit codes, and identical saved configuration bytes. Add the user-visible fix to the unreleased changelog.

Related issue

Fixes #188

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • Tests added/updated
  • Manual testing performed

Windows, Python 3.13.5:

  • Before the fix, python -m pytest tests/test_quiet_mode.py -k budget_set_quiet -q: 4 failed, all on the unexpected quiet output.
  • After the fix, python -m pytest tests/ -v --cov=agentcost --cov-report=term-missing with COLUMNS=200 as documented in CONTRIBUTING.md: 220 passed, overall coverage 73%.
  • git diff --check: passed.

The repository's Linux/Python 3.10–3.13 CI matrix passed all four jobs for commit ef9fd83985999cce611e7a96687c4919e1e2e75d.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • CI passes

Notes

Prepared with Codex assistance; the reproduction and test results above were executed locally.

Copilot AI balanced review requested due to automatic review settings October 3, 2026 12:50

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yunaremaia

Copy link
Copy Markdown
Owner

Nice, focused fix — and thanks for including the reproduction steps up front. Confirmed everything independently on both commits; all green.

What I reproduced

Real CLI (python -m agentcost.cli), throwaway HOME, both flags, base main @ 7d36938 vs your head @ ef9fd83:

agentcost budget set --daily 5 --weekly 25 --monthly 100 [--quiet|-q]

Base (main) — bug confirmed. The "Budget thresholds saved" line was correctly suppressed, but the three per-period lines leaked past the guard:

$ agentcost budget set --daily 5 --weekly 25 --monthly 100 --quiet
  Daily: $5.00
  Weekly: $25.00
  Monthly: $100.00
exit=0

Head (ef9fd83) — fixed. Both --quiet and -q produce zero stdout, exit 0:

$ agentcost budget set --daily 5 --weekly 25 --monthly 100 --quiet
exit=0   # stdout empty

The saved config is byte-identical between base and head, and identical between the quiet and non-quiet runs ([budget] daily = 5.0 / weekly = 25.0 / monthly = 100.0) — so this is purely an output-suppression fix, with no change to what gets persisted. Exactly what the flag's help text ("Suppress console messages (exit code only)") promises.

I also probed the neighbouring paths for regressions: no-thresholds, --daily 0, --daily abc, --quiet --sarif, and --daily 5 alone. Exit codes and messages are unchanged on both commits, so the guard placement doesn't swallow errors.

Tests — red/green confirmed

  • Red: your test_budget_set_quiet copied onto base source → 4 failed, all on assert quiet.output == "", exactly the four parametrized cases ({daily} and {daily,weekly,monthly} × --quiet/-q).
  • Green: same test on head → 4 passed.
  • Full suite: 216 passed on base, 220 passed on head. Matches the 220 you reported.
  • git diff --check: clean.

Scope

Tight — no scope creep. git diff -w on cli.py is empty, which proves the source change is a pure re-indentation of three existing console.print calls into the if not quiet: block, with not one logical edit. Nice and minimal. The only other changes are the one-line ### Fixed CHANGELOG entry under [Unreleased] (correctly worded, and it names the issue) and the new tests.

CI

All four legs of the matrix green: test (3.10), test (3.11), test (3.12), test (3.13) — run 37124209046, all SUCCESS.

One optional follow-up (not blocking, not for this PR)

budget show still prints even under --quiet (e.g. No budget thresholds set.). That's pre-existing and outside what #188 describes, so no need to touch it here — but if --quiet is meant to be uniform across the budget subcommands, it might be worth its own issue. Your call entirely.

Merging this as a squash. Nice first contribution — the bug report, the changelog entry, and a parametrized test that covers both flag spellings and both the single- and multi-threshold cases is exactly the shape I'd want to see.

@yunaremaia
yunaremaia merged commit 1d1674b into yunaremaia:main Oct 3, 2026
4 checks passed
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.

bug: budget set --quiet still prints the budget lines to stdout

3 participants