fix(headless): persist tool calls on -p --session (resume cutoff); mermaid validation - #407
Merged
Conversation
added 2 commits
June 11, 2026 18:43
The headless save stored only the user prompt + the assistant's final text, dropping every tool call/result. So a resumed --session (e.g. an MCP delegation follow-up) lost the actual work history, and a tool-heavy final turn — which often has little or no trailing text — saved an empty/thin assistant message that read as a cut-off end. run_print now accumulates the turn's ToolCall/ToolResult events (mirroring the interactive run_handlers) and returns them; the print path saves via add_message_with_tool_calls so convert_history re-emits the tool_use / tool_result blocks on resume. The --loop caller ignores them. Verified live: 'dirge -p --session X "create a file"' now saves the assistant message with tool_calls=[write, read] instead of 0.
- Edge check only matched --> / ->> / ---, so valid er/class/state
diagrams (and flowchart -.-> / ==>) were rejected for 'no connections'.
Broaden to the common --/->> /==>/-.- connectors.
- Add a {}-balance check ({decision}/{{hexagon}} nodes were unchecked).
- Drop a stray '[' from the unbalanced-brackets error message.
- max-retries is never reassigned — def, not var.
Parses clean (janet parse-all).
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.
The resume "cutoff" bug
Found while testing the MCP delegation loop.
dirge -p --session <id>saved the conversation, but the assistant message stored only its final text — every tool call/result was dropped (verified: a saved MCP session hadtool_calls=0on assistant turns that actually wrote/edited files). Consequences on resume:--session(e.g. an MCP delegation follow-up) lost the substance of prior turns — dirge saw "I did X" but not what the tools actually did.(The companion resume fix — feeding the loaded history back to the model at all — already shipped in #406. This adds full fidelity.)
Fix:
run_printnow accumulates the turn'sToolCall/ToolResultevents (mirroring the interactiverun_handlers/tool_call.rs+tool_result.rs) and returns them; the print path saves viaadd_message_with_tool_calls, soconvert_historyre-emits thetool_use/tool_resultblocks on resume. The--loopcaller ignores them.Verified live:
dirge -p --session X "create a file FOO.txt"now saves the assistant message withtool_calls=[write, read]instead of0.Plugin review:
plugins/mermaid_diagram.janetReviewed as requested. The structure is sound (the stem-prefixed hook names are a supported form;
request-prompt/append-system-prompt/3-argadd-custom-messageall exist). Fixed validation gaps invalidate-diagram:-->/->>/---, so valider/class/statediagrams (and flowchart-.->/==>) were rejected for "no connections". Broadened to--/->>/==>/-.-.{}-balance check ({decision}/{{hexagon}}nodes were unchecked).[from the unbalanced-brackets error message.max-retries→def(never reassigned).Parses clean (
janet parse-all).Tests
Full suite 2612 pass;
run_printsignature change covered by the existing print tests + live verification.