An agent's answer is readable in the chat and the property panel - #57
Merged
Merged
Conversation
A wfpy agent finishes a turn by writing its ports, and the runtime reports that as one JSON object whose port values are themselves JSON. The text reaching the chat is therefore escaped twice: a unified diff arrives as a single line of \n and \" and renders as one unreadable paragraph, which is what the planner's rounds have looked like all along. agent-outputs.ts turns such a message into Markdown, which the panel already parses and sanitizes: a heading per port, one line per scalar field, and a fenced block for anything long, tagged diff when it is one. Scalars come before blocks so the options and the reason read before the patch. Prose keeps its punctuation; an option string gets backticks. A value carrying its own fence gets a longer one. Anything that is not an outputs object returns null and goes through untouched, so ordinary replies are unaffected.
Two faults on the same values the chat now formats. A port's value is itself JSON, so the tree showed one escaped string truncated at 500 characters instead of the fields inside it. And a diff went through the Markdown heuristic, whose list rule matches a line beginning with a dash and a space, which is every removed line: a patch rendered as a bullet list with its minus signs eaten. The string branch now unwraps an embedded JSON value and recurses, and sends a diff or any multi-line string to a scrolling pre instead. The three predicates are shared with the chat's formatter rather than copied, so the two panels agree on what a diff is.
Gate 1 of the neutrality check refuses the product names in packages/*/src, and the doc comment opened "A wfpy agent finishes a turn". The sentence says the same thing about any agent that writes ports, so the name was carrying nothing.
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.
A wfpy agent finishes a turn by writing its ports, and the runtime reports that as one JSON object whose port values are themselves JSON. The text reaching the UI is escaped twice, so a unified diff arrives as a single line of
\nand\". In the chat it rendered as one unreadable paragraph. In the property panel it was worse: the value was truncated at 500 characters, and what did show went through the Markdown heuristic, whose list rule matches any line beginning with a dash and a space, which is every removed line of a patch. A diff therefore rendered as a bullet list with its minus signs eaten, which silently changes what the patch appears to say.What changed
agent-outputs.tsis a new module with one job: turn an outputs object into Markdown the panel already parses and sanitizes. A heading per port, one line per scalar field, a fenced block for anything long, taggeddiffwhen it is one. Scalars come before blocks so the options and the reason read before the patch. Prose keeps its punctuation while an option string gets backticks. A value carrying its own fence gets a longer one. Anything that is not an outputs object returns null and goes through untouched, so ordinary replies are unaffected.The property panel shares that module's three predicates rather than copying them, so the two views cannot drift on what counts as a diff. Its string branch now unwraps an embedded JSON value and recurses into the tree, and sends a diff or any multi-line string to a scrolling monospace block styled from the editor's own tokens.
Before and after
A planner's round, as the chat showed it:
and as it shows it now:
Testing
Nine tests on the new module, including a real planner answer from a run, a bullet list that must not be taken for a diff, a broken JSON string that must be returned untouched, and a value containing its own fence. The package's 198 tests pass and all five packages type-check.