Skip to content

Include StructuredToolResult.url in LLM tool messages - #2291

Closed
sahilleth wants to merge 1 commit into
HolmesGPT:masterfrom
sahilleth:fix/2289-tool-result-url-in-llm-message
Closed

Include StructuredToolResult.url in LLM tool messages#2291
sahilleth wants to merge 1 commit into
HolmesGPT:masterfrom
sahilleth:fix/2289-tool-result-url-in-llm-message

Conversation

@sahilleth

@sahilleth sahilleth commented Jul 14, 2026

Copy link
Copy Markdown

Summary

Fixes #2289.

StructuredToolResult.url was already exposed to API clients via tool_calls[].result.url, but format_tool_result_data() never included it in the tool message sent back to the LLM. That led the model to invent invalid links (observed with VictoriaLogs external_url).

This appends Result URL: <url> to the LLM tool content when a URL is present, and adds a regression test covering to_llm_message() vs to_client_dict().

Test plan

  • pytest tests/core/test_models.py::TestToolCallResultUrlInLlmMessage
  • Full tests/core/test_models.py (10 passed)

Summary by CodeRabbit

  • Bug Fixes

    • Tool results now include their source URL in generated messages when available, and omit it when no URL is provided.
    • Ensured the URL is consistently exposed to clients as part of the tool result output.
  • Tests

    • Added regression coverage verifying URL inclusion/omission for both client serialization and generated message content.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ac9be87-dc16-4793-80c9-f87710a3c657

📥 Commits

Reviewing files that changed from the base of the PR and between 98f68bb and dd1baf9.

📒 Files selected for processing (2)
  • holmes/core/models.py
  • tests/core/test_models.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/core/test_models.py
  • holmes/core/models.py

Walkthrough

Adds conditional StructuredToolResult.url serialization to LLM tool messages and regression tests for URL-present and URL-absent results.

Changes

Tool result URL propagation

Layer / File(s) Summary
URL formatting and regression tests
holmes/core/models.py, tests/core/test_models.py
format_tool_result_data appends a Result URL: line when a URL is provided; tests verify client and LLM outputs with and without a URL.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main change to include StructuredToolResult.url in LLM tool messages.
Linked Issues check ✅ Passed The change addresses [#2289] by adding result URLs to LLM tool messages while keeping the client-facing result.url intact.
Out of Scope Changes check ✅ Passed The diff stays focused on the reported URL serialization bug and its regression tests, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploy Preview for holmes-docs ready!

Name Link
🔨 Latest commit dd1baf9
🔍 Latest deploy log https://app.netlify.com/projects/holmes-docs/deploys/6a5653aeab844200083e6a0b
😎 Deploy Preview https://deploy-preview-2291--holmes-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Without this, clients see the real result URL while the model does not,
so final answers can invent invalid links (e.g. victorialogs://...).

Fixes HolmesGPT#2289

Signed-off-by: Sahil Bhardwaj <sahillbhardwaj23@gmail.com>
@sahilleth
sahilleth force-pushed the fix/2289-tool-result-url-in-llm-message branch from 98f68bb to dd1baf9 Compare July 14, 2026 15:20
@sahilleth sahilleth closed this Aug 7, 2026
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.

StructuredToolResult.url is omitted from LLM tool messages, causing hallucinated result links

1 participant