Skip to content

[CLI] Make --format human override agent auto-detection - #4878

Open
hanouticelina wants to merge 5 commits into
mainfrom
cli-format-human-override
Open

[CLI] Make --format human override agent auto-detection#4878
hanouticelina wants to merge 5 commits into
mainfrom
cli-format-human-override

Conversation

@hanouticelina

@hanouticelina hanouticelina commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Related to #4860.

Summary

  • When a registered harness is detected, auto resolves to agent. Passing --format human restored the layout but not the rest: progress bars were disabled once at import and never re-enabled, and ANSI called is_agent() directly so colors stayed off.
  • set_mode() now derives everything from the resolved mode: progress bars on for human, off otherwise (unless HF_HUB_DISABLE_PROGRESS_BARS is set, which keeps priority), and it tells ANSI whether colors are on.
  • ANSI.set_enabled() is the new toggle. Callers outside the hf CLI (login flow, tiny-agents CLI) don't set it and fall back to is_agent() as before. NO_COLOR still wins.
  • Side effect: colors are now off in json and quiet too, not only agent. Seems right for machine-oriented modes.
  • User-agent attribution and hf env are unchanged and keep using detect_agent().

Example

In a pty with TERM_PROGRAM=WarpTerminal, which is detected as the warp harness:

Before, --format human gave the human layout but no progress bar and no colors:

$ hf download sentence-transformers/all-MiniLM-L6-v2 onnx/model_qint8_arm64.onnx --local-dir /tmp/x --format human
✓ Downloaded
  path: /tmp/x/onnx/model_qint8_arm64.onnx

After:

$ hf download sentence-transformers/all-MiniLM-L6-v2 onnx/model_qint8_arm64.onnx --local-dir /tmp/x --format human
onnx/model_qint8_arm64.onnx: reconstructing file: 100% 23.0M/23.0M [00:01<00:00, 14.5MB/s]
✓ Downloaded   <- green
  path: /tmp/x/onnx/model_qint8_arm64.onnx

Without --format, the same command still resolves to agent mode (path=..., no bars).


Note

Low Risk
CLI presentation only; respects existing env overrides and preserves non-CLI ANSI behavior via is_agent() fallback.

Overview
--format human now fully overrides agent harness detection for terminal UX, not just layout.

Output.set_mode() ties ANSI colors and progress bars to the resolved format: human turns both on; agent, json, and quiet turn colors off and progress bars off unless HF_HUB_DISABLE_PROGRESS_BARS is already set (env still wins).

ANSI gains set_enabled() and an internal override so the hf CLI drives coloring from output mode; other callers keep the previous is_agent() fallback. NO_COLOR is unchanged and still disables styling.

Reviewed by Cursor Bugbot for commit b9abfa1. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@hanouticelina
hanouticelina marked this pull request as ready for review September 11, 2026 13:33
Comment thread src/huggingface_hub/cli/_output.py Outdated

@Wauplin Wauplin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice fix, thanks you! Pre-approving with a nit :)

Co-authored-by: Lucain <lucain@huggingface.co>
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.

2 participants