Skip to content

fix(DATAGO-130049): workflow node agents hallucinate tool name instead of using inline artifact block - #1551

Merged
cyrus2281 merged 4 commits into
mainfrom
cyrus/DATAGO-130049/workflow-artifacts
May 27, 2026
Merged

fix(DATAGO-130049): workflow node agents hallucinate tool name instead of using inline artifact block#1551
cyrus2281 merged 4 commits into
mainfrom
cyrus/DATAGO-130049/workflow-artifacts

Conversation

@cyrus2281

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1261.

_generate_workflow_instructions in structured_invocation/handler.py injected this instruction into every workflow node agent prompt:

- Use the save_artifact tool OR inline fenced blocks to create the output artifact

save_artifact is not a registered tool — it is the keyword used inside the inline fenced block syntax («««save_artifact:...»»»). When an LLM reads "use the save_artifact tool" and cannot find it in its tool list, it invents a plausible-sounding name ($ARTIFACT_TOOL, $RESULT_TOOL) and attempts a function call with that hallucinated name. SanitizeToolNames strips the invalid call, the artifact is never created, and the node retries — wasting an extra LLM round-trip on every workflow node invocation.

Note: append_to_artifact is also not the right guidance here — it only appends to an existing artifact. The correct mechanism for creating an artifact from scratch in a workflow node is the inline fenced block syntax, which is text-parsed (not a tool call).

Fix: Replace the ambiguous instruction with one that names the correct mechanism and explicitly states it is NOT a tool call:

- Create the output artifact using the inline fenced block syntax («««save_artifact: filename=... mime_type=...»»»), NOT a tool call

Changes

  • src/solace_agent_mesh/agent/sac/structured_invocation/handler.py — one-line prompt fix
  • tests/unit/agent/sac/test_workflow_instructions.py — new unit tests for _generate_workflow_instructions output
  • tests/integration/scenarios_declarative/test_data/workflows/test_workflow_correct_artifact_tool_in_prompt.yaml — new declarative regression test using StructuredTestWorkflow (which has output_schema_override on nodes, triggering the exact affected branch)

Test plan

  • pytest tests/unit/agent/sac/test_workflow_instructions.py -v — 7 unit tests pass
  • pytest tests/integration/scenarios_declarative/test_declarative_runner.py -k "workflows" -v — all 13 workflow declarative tests pass including the new regression test
  • Real-LLM end-to-end: trigger a structured workflow node and confirm no SanitizeToolNames WARNING / retry log lines appear

Copilot AI review requested due to automatic review settings May 21, 2026 15:38
@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

✅ FOSSA Guard: Licensing (SolaceLabs_solace-agent-mesh) • PASSED

Compared against main (35ff2d14f791f35e48af6a6ef10b30e0166f9013) • 0 new, 5 total (5 in base)

Scan Report | View Details in FOSSA

@github-actions

github-actions Bot commented May 21, 2026

Copy link
Copy Markdown

✅ FOSSA Guard: Vulnerability (SolaceLabs_solace-agent-mesh) • PASSED

Compared against main (35ff2d14f791f35e48af6a6ef10b30e0166f9013) • 0 new, 2 total (2 in base)

Scan Report | View Details in FOSSA

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes workflow-node prompt guidance that incorrectly referred to a non-existent save_artifact tool, which caused models to hallucinate tool names and trigger avoidable retries during structured workflow node execution (issue #1261).

Changes:

  • Update _generate_workflow_instructions to explicitly instruct using the inline «««save_artifact: ...»»» fenced block syntax (and that it is not a tool call).
  • Add unit tests to prevent regressions in workflow instruction text.
  • Add an integration declarative regression scenario asserting tool presence/absence and no retry behavior.
  • Update README image URLs (currently introduces a hard-coded raw GitHub URL and changes the bottom logo asset).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/solace_agent_mesh/agent/sac/structured_invocation/handler.py Fixes ambiguous prompt text to prevent hallucinated tool calls during workflow node executions.
tests/unit/agent/sac/test_workflow_instructions.py Adds unit coverage ensuring workflow instructions don’t mention save_artifact as a tool and include the correct guidance.
tests/integration/scenarios_declarative/test_data/workflows/test_workflow_correct_artifact_tool_in_prompt.yaml Adds regression test scenario validating tool list and successful artifact+result flow without retry.
README.md Changes image sources to raw GitHub URLs and alters the bottom logo reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/solace_agent_mesh/agent/sac/structured_invocation/handler.py Outdated
Comment thread README.md
@@ -1,5 +1,5 @@
<p align="center">
<img src="./docs/static/img/logo.png" alt="Solace Agent Mesh Logo" width="100"/>
<img src="https://raw.githubusercontent.com/SolaceLabs/solace-agent-mesh/refs/heads/main/docs/static/img/logo.png" alt="Solace Agent Mesh Logo" width="100"/>
Comment thread README.md

<h3 align="center">
<img src="./docs/static/img/solace-logo-text.svg" alt="Solace Agent Mesh Logo" width="100"/>
<img src="https://raw.githubusercontent.com/SolaceLabs/solace-agent-mesh/refs/heads/main/docs/static/img/logo.png" alt="Solace Agent Mesh Logo" width="100"/>
@cyrus2281 cyrus2281 changed the title fix: workflow node agents hallucinate tool name instead of using inline artifact block fix(DATAGO-130049): workflow node agents hallucinate tool name instead of using inline artifact block May 21, 2026

@enavitan enavitan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, please don't forget to update the suggested example to include quotes

Thanks
Eugene

@cyrus2281
cyrus2281 enabled auto-merge (squash) May 27, 2026 15:36
@sonarqube-solacecloud

Copy link
Copy Markdown

@cyrus2281
cyrus2281 merged commit 38d337c into main May 27, 2026
25 of 27 checks passed
@cyrus2281
cyrus2281 deleted the cyrus/DATAGO-130049/workflow-artifacts branch May 27, 2026 16:17
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.

Workflow node agents hallucinate $ARTIFACT_TOOL / $RESULT_TOOL instead of calling append_to_artifact

3 participants