Skip to content

fix: warn that --format does not change files written by agents-as-code commands - #176

Open
danieldutu wants to merge 2 commits into
elevenlabs:mainfrom
danieldutu:fix/workflow-format-flag-warning
Open

danieldutu wants to merge 2 commits into
elevenlabs:mainfrom
danieldutu:fix/workflow-format-flag-warning

Conversation

@danieldutu

@danieldutu danieldutu commented Oct 24, 2026 •

Copy link
Copy Markdown

elevenlabs agents pull --format yaml exited 0 and wrote JSON files. Nothing said that --format had no effect. The same is true for agents push, tools push/pull and tests push/pull. --format is declared with global(true) on the root command in src/app.rs, so clap accepts it on every subcommand. These six commands read or write local JSON configs and never pass a response to the formatter.

Changes:

  • CliApp::ignores_format(path, noun, verb) (src/app.rs) records on the registered CliCommand that the command ignores --format.
  • Custom-command dispatch in CliApp prints one line on stderr before it calls the handler, and only when --format was given: --format controls how API responses are printed and has no effect on <command>; <noun> are always <verb> as JSON.
  • The six push/pull commands declare it where they register, each with its own noun and verb. For example, tools push warns that "tool configs are always read as JSON", and agents pull warns that "agent configs are always written as JSON". A future command gets the warning from one builder call.
  • The --format help text and the README now say that the flag styles printed API responses only.
  • tests/format_flag_test.rs is listed in .fernignore with the other hand-written tests, so a regeneration keeps it.

Evidence:

  • tests/format_flag_test.rs runs the built binary with ELEVENLABS_BASE_URL pointed at a closed localhost port, so no request leaves the machine. It covers agents pull --format yaml, --format yaml agents pull, tools push --format json, tests pull --format table, and agents pull without the flag. It asserts the exact warning text in the first four cases and no warning in the fifth.
  • I removed .global(true) from the --format arg as a check. 4 of the 5 tests then failed.
  • cargo test, cargo test --manifest-path elevenlabs-types/Cargo.toml and cargo test --manifest-path elevenlabs-sdk/Cargo.toml pass with 0 failures.

Boundaries: the change does not alter what --format does, and it does not reject the flag. A hard error would break scripts that already pass --format to every command. agents init/add/status are typed commands. They can use the same declaration, but I did not add it. I tested on macOS only.

Fixes #171.

@PaulAsjes PaulAsjes 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.

Thanks, but I think we can make a few optimizations here.

Comment thread cli/elevenlabs/workflow/util.rs Outdated
pub fn warn_format_ignored(matches: &clap::ArgMatches, command: &str) {
if format_flag(matches).is_some() {
eprintln!(
"--format controls how API responses are printed and has no effect on {command}; agent configs are always written as JSON."

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.

This text will be wrong for anything that isn't an agent config (e.g. tools, tests, push command). The caller should pass in the noun and the verb.

Comment thread cli/elevenlabs/workflow/agents.rs Outdated

fn handle_push(matches: &clap::ArgMatches, ctx: &AppContext) -> Result<(), CliError> {
let _scope = api::command_scope("agents.push");
warn_format_ignored(matches, "agents push");

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.

Instead of fixing this at the handler level (and having to remember to add this to any future handlers) we should fix it at the source in CliCommand that makes CliApp dispatch the warning.

Comment thread cli/elevenlabs/workflow/util.rs Outdated
}

#[test]
fn format_flag_reads_the_flag_before_the_subcommand() {

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.

The tests don't exercise the real path. They use a made-up clap tree and never call warn_format_ignored or the real CliApp command tree. A change to how globals are attached in src/app.rs:1225-1260 would break the warning while both tests still pass.

…ispatch

The first version called warn_format_ignored inside six push/pull handlers.
Every future handler had to remember the call. The message also said "agent
configs" for tools and tests. Its two unit tests ran on a hand-built clap tree,
so they never touched the real global flag.

CliApp::ignores_format(path, noun, verb) now records the declaration on the
registered CliCommand. Dispatch prints the warning once on stderr before it
calls the handler, and only when --format was given. The agents, tools and
tests push/pull commands declare it where they register. Each declaration
gives its own noun ("agent configs", "tool configs", "test configs") and verb
("read" for push, "written" for pull). I removed format_flag,
warn_format_ignored and their tests from util.rs.

tests/format_flag_test.rs runs the built binary on five argv cases. Removing
.global(true) from the --format arg in src/app.rs makes 4 of the 5 fail.
@danieldutu

Copy link
Copy Markdown
Author

Thanks for the review. I pushed a new commit on top of the first one.

  1. Message text (util.rs:42). The caller now passes the noun and the verb. Each command declares its own pair, for example tools push with "tool configs" and "read", and tests pull with "test configs" and "written". The tests tools_push_warns_with_its_own_noun and tests_pull_warns_with_its_own_noun pin the text.

  2. Fix at the source (agents.rs:617). CliCommand has a new format_ignored field (src/app.rs:50), set by CliApp::ignores_format(path, noun, verb) (src/app.rs:511). Custom-command dispatch prints the warning once on stderr before it calls the handler, and only when --format was given (src/app.rs:1161). The six handler calls and the util.rs helpers are gone. The six commands declare it in register (agents.rs:52-53, tools.rs:39-40, tests.rs:40-41). The tests agents_pull_warns_with_format_after_the_command and no_warning_without_format pin this.

  3. Tests on the real path (util.rs:114). I deleted the made-up-tree tests. tests/format_flag_test.rs runs the built binary, so it uses the same tree that main builds. ELEVENLABS_BASE_URL points at a closed localhost port, so no request leaves the machine. When I removed .global(true) from the --format arg, 4 of the 5 tests failed, including agents_pull_warns_with_format_before_the_command. The new file is listed in .fernignore next to the other hand-written tests.

Not covered: agents init/add/status are typed commands. They can take the same declaration with one line each, but I did not add it, because add and status print output that --format may affect. Should I declare any of them here, or leave that for a follow-up?

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.

--format on agents pull is misleading: it doesn't affect the on-disk config format

2 participants