feat(engine): auto-parse script agent JSON stdout into output fields#122
Open
PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
Open
feat(engine): auto-parse script agent JSON stdout into output fields#122PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
PolyphonyRequiem wants to merge 2 commits intomicrosoft:mainfrom
Conversation
When a script agent's stdout is valid JSON, the parsed fields are now merged into the output dict alongside stdout/stderr/exit_code. This makes parsed fields accessible in route conditions and downstream templates as output.field_name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
daa7b50 to
8d72ee3
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #122 +/- ##
=======================================
Coverage ? 84.90%
=======================================
Files ? 53
Lines ? 7174
Branches ? 0
=======================================
Hits ? 6091
Misses ? 1083
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add debug-level logging when a script's parsed JSON output contains keys that shadow the built-in stdout/stderr/exit_code fields. Makes the intentional shadowing behavior observable for debugging. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
When a script agent's stdout is valid JSON, the parsed fields are now merged into the output dict alongside
stdout/stderr/exit_code. This makes parsed fields accessible in route conditions and downstream templates asoutput.field_name— matching LLM structured output behavior.Motivation
Script agents are the deterministic workhorses of conductor workflows (P8). They emit structured data via JSON stdout, but currently that data is only accessible as a raw string (
output.stdout). Routing on specific fields requires opaque exit codes instead of readable field-based conditions.Before:
After:
Changes
src/conductor/engine/workflow.py: After capturing script output, attemptjson.loads(stdout). If it parses as a dict, merge fields intooutput_content(7 lines).tests/test_engine/test_workflow.py: End-to-end test verifying JSON parsing, field access, and field-based routing.Design decisions
stdout,stderr,exit_codealways present. Non-JSON stdout is unchanged. JSON arrays/scalars are ignored (only objects merged).stdout/stderr/exit_codeif a script outputs those as JSON keys. This is intentional: scripts that output{"exit_code": 42}probably want the JSON value to win over the raw field.Testing