Skip to content

fix(flow): render composite ${args.*} values as JSON in prompts (CD-4975) - #55

Open
obukhovaa wants to merge 1 commit into
mainfrom
fix/cd-4975-flow-args-json-rendering
Open

fix(flow): render composite ${args.*} values as JSON in prompts (CD-4975)#55
obukhovaa wants to merge 1 commit into
mainfrom
fix/cd-4975-flow-args-json-rendering

Conversation

@obukhovaa

Copy link
Copy Markdown
Owner

Problem

A ${args.X} placeholder that resolves to a map/slice — typically a prior step's structured-output field merged into args — was rendered with fmt.Sprintf("%v", ...), leaking Go's [map[k:v] ...] notation into step prompts. Observed in the scheduled cancel-survey-audit run (C3 scheduler → c3.workflow.run_requested): the verify step received

Declared figures to check: [map[claim:Total cancel events source:get_engagement_buckets.total_cancel_events unit:count value:1882] map[...]]

That 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

substituteScoped now routes resolved ${args.PATH} values through renderTemplateValue: map[string]any / []any render 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 through json.Unmarshal (flow-state rows, struct-output merge, /flow/run body).

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

…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>
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.

1 participant