fix: render const values as literals in output format instruction (#129) #130
Reference in New Issue
Block a user
Delete Branch "fix/129-const-prompt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Fix
buildOutputFormatInstructionto renderconstfield values as literals instead of type placeholders.Why
When a schema has
$status: { type: string, const: greeted }, the prompt was showing$status: <string>, causing agents to output$status: constinstead of the actual valuegreeted. (#129)Changes
util-agent/src/build-output-format-instruction.ts:resolvePropertySchema(): early return forconstproperties (same asenum)buildPropertyExampleLine(): newconstbranch renders literal value with# fixed valuecommentutil-agent/__tests__/build-output-format-instruction.test.ts: +2 tests (string const, non-string const)Before / After
$status: <string> # required$status: greeted # required | fixed valueTest
812/812 passing (+2 new)
Ref
Fixes #129
LGTM ✅
resolvePropertySchema()的 const early return 防止被 union 吞掉,buildPropertyExampleLine()输出实际值而不是<string>。修完后 agent 看到的是$status: greeted # required | fixed value,不会再输出$status: const了。