fix(flow): render composite ${args.*} values as JSON in prompts (CD-4975) - #55
Open
obukhovaa wants to merge 1 commit into
Open
fix(flow): render composite ${args.*} values as JSON in prompts (CD-4975)#55obukhovaa wants to merge 1 commit into
obukhovaa wants to merge 1 commit into
Conversation
…975)
A ${args.X} placeholder resolving to a map/slice (a prior step's
struct-output field merged into args) was rendered with fmt's %v,
leaking Go's `[map[k:v] ...]` notation into prompts — lossy (unquoted,
ambiguous around spaces) and hard for the model to consume. Seen in the
scheduled cancel-survey-audit run: `${args.cited_figures}` reached the
verify step as a Go map dump.
Composite values now render as compact JSON; scalar rendering is
unchanged (strings substitute verbatim), and bare ${args} already
dumped JSON.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Problem
A
${args.X}placeholder that resolves to a map/slice — typically a prior step's structured-output field merged into args — was rendered withfmt.Sprintf("%v", ...), leaking Go's[map[k:v] ...]notation into step prompts. Observed in the scheduledcancel-survey-auditrun (C3 scheduler →c3.workflow.run_requested): theverifystep receivedThat form is lossy (unquoted values, ambiguous around spaces) and hard for the model to consume mechanically. The trigger path is irrelevant — any flow interpolating a composite arg into a later prompt is affected.
Fix
substituteScopednow routes resolved${args.PATH}values throughrenderTemplateValue:map[string]any/[]anyrender as compact JSON; scalar rendering is unchanged (strings substitute verbatim, so"${args.aid}"-style quoting in prompts stays valid). Bare${args}already dumped JSON. Only the JSON-shaped types are matched because every args value passes throughjson.Unmarshal(flow-state rows, struct-output merge,/flow/runbody).Docs (
docs/flows.md→ Template Substitution) updated; two new unit tests cover the array-of-objects (cited_figures-shaped) and whole-object cases.Tracked by CD-4975 (epic CD-4552).
🤖 Generated with Claude Code