Repository navigation
Fix --inputs-file: inputs from a JSON file or stdin never reach the objective - #37
Open
rr-aniket-wankhede wants to merge 1 commit into
Open
rr-aniket-wankhede wants to merge 1 commit into
rr-aniket-wankhede wants to merge 1 commit into
Conversation
The run command's flag loop treated --inputs-file as an input named inputs_file whose value was the path, so inputs from a file or stdin never reached the objective: the worker saw every declared input as missing and failed the task before calling the model (llm_calls: 0). --inputs-file now reads the file (or stdin via -), parses the JSON object, and merges it into the same invoke context the flags build. Also fix the flag parser mangling dashes in --flag=value (it normalized the whole token before splitting on =), which --inputs-file=<path> needs and which silently corrupted any value containing a dash.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
--inputs-fileis documented in DESIGN.md but was never implemented. Theruncommand parses its extra args as declared-input flags, so the token was consumed
as an input named
inputs_filewhose value was the path. The real inputs neverarrived, and the task failed before the model was invoked.
Root cause:
charter/cli.pyinrun(): the flag loop (key = token[2:].replace("-", "_")→context[key] = _typed(value)) has no special case for--inputs-file, so the flag-path and file-path never converge on the same invoke context.Repro
Agent config used:
The fix
run()now recognises--inputs-file(space,=, and-for stdin) and mergesthe parsed JSON object into the same
invoke_workflow(context=...)the flagsbuild (
_read_inputs). A file that is missing, unparsable, or not a JSON objectis refused locally with a clear error, without submitting a request.
While testing this, the
=form exposed a latent parser bug that the fix alsocorrects: the loop replaced
-with_across the whole token before splittingon
=, so any--flag=value-with-dasheswas silently mangled (--inputs-file=/some-pathbecame
/some_path). The split now happens first, so only the flag name is normalized.Tests
tests/test_cli.py::TestRunInputsFile): the CLI path with a file,stdin
-, the=form mixed with flags, and local refusal of bad filesall asserting the exact context handed to
invoke_workflow.tests/e2e/test_inputs_file.py): the realcharter runcommand in asubprocess, against a real control plane and store, with a scripted model that
asserts the objective the model is handed contains the rendered value, the
structured result, and
total_llm_calls == 1(the bug showed0).Full suites pass: 345 unit tests, 31 e2e (4 skipped: no live providers locally).