Skip to content

Simplify evaluator notebook output with a <result uuid> marker#215

Merged
rhennigan merged 1 commit into
mainfrom
feature/wl-output-cleanup
Jul 9, 2026
Merged

Simplify evaluator notebook output with a <result uuid> marker#215
rhennigan merged 1 commit into
mainfrom
feature/wl-output-cleanup

Conversation

@rhennigan

Copy link
Copy Markdown
Member

Summary

Cleans up the WolframLanguageEvaluator (and WolframAlpha) UI-path tool output when a notebook is embedded. The verbose agent-facing marker is replaced with a compact <result uuid="…"> wrapper around the output, and the session reminder is shortened to one line.

Before

Out[1]= 2543568463<internal>This tool call was displayed to the user as an interactive notebook, which they can already see. The URL below only renders that notebook; you do not need to read, repeat, visit, or otherwise use it. <url>https://www.wolframcloud.com/obj/rhennigan/AgentTools/Notebooks/68f8eee5773a415e.nb</url></internal>

<system-reminder>Wolfram session ID: Ei685Jkk. To continue this session (its definitions, line numbers, and history) in your next call to this tool, pass session="Ei685Jkk". Omit the session parameter only to start a new, empty session.</system-reminder>

After

<result uuid="e0f29bea-667b-4780-b36b-59de225e660e">
Out[1]= 2543568463
</result>

<system-reminder>Pass session="Ei685Jkk" in future calls to this tool to continue this session.</system-reminder>

How it works

  • Notebooks deploy with CloudObjectNameFormat -> "UUID", so the deployed URL is already https://www.wolframcloud.com/obj/<uuid> — no extra Information round-trip. The hashed deploy path is kept, so identical evaluations still dedup to one stable object (same path → same UUID).
  • makeNotebookUIResult wraps the content in <result uuid="…">…</result> (wrapResultTags); cloudNotebookUUID pulls the uuid out of the deployed URL.
  • Each viewer (evaluator, wolframalpha, notebook) reconstructs the identical cloud URL from the marker's uuid when a host drops _meta (ext-apps#696), and stripAgentOnlyText removes the <result> tags while preserving the inner result text.
  • URL recovery prefers the first marker (the server prepends the opening tag), so a <result uuid="…"> string appearing in user evaluation output — which can only come after the server's tag — can't hijack the embedded URL.

Test plan

  • TestReport on MCPApps.wlt, EvaluatorSessions.wlt, WolframLanguageEvaluator-UI.wlt, WolframAlpha-UI.wlt158/158 pass. Includes the rewritten marker tests and a new cloudNotebookUUID test.
  • CodeInspector clean on the changed .wl files (only pre-existing FIXME warnings remain).
  • Real end-to-end deploy of Prime[123456789] through the updated pipeline produces exactly the "After" output, with _meta.notebookUrl's uuid matching the marker.
  • Viewer JS extracted from the shipped HTML and executed: recovers the URL matching _meta, resists the injection case (server's real uuid wins), strips to clean Out[1]= 2543568463, and returns null when no marker is present.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YXQ4f3K8pZyuMtV2aii21q

Replace the verbose <internal>...<url>...</url></internal> notebook-URL marker
with a compact <result uuid="..."> wrapper around the evaluation output, and
shorten the session <system-reminder> to a single line. This applies to both
WolframLanguageEvaluator and WolframAlpha, which share makeNotebookUIResult.

Notebooks now deploy with CloudObjectNameFormat -> "UUID", so the deployed URL is
already https://www.wolframcloud.com/obj/<uuid> (no extra Information round-trip)
while keeping the hashed deploy path, so identical evaluations still dedup to one
stable object. When a host drops _meta (ext-apps#696), each viewer reconstructs
the same URL from the marker's uuid, and stripAgentOnlyText removes the <result>
tags while preserving the wrapped result text.

URL recovery now prefers the FIRST marker (the server prepends the opening tag),
so a <result uuid="..."> string appearing in user evaluation output — which can
only come after the server's tag — can no longer hijack the embedded URL.

Tests and docs updated accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YXQ4f3K8pZyuMtV2aii21q
Copilot AI review requested due to automatic review settings July 9, 2026 19:37

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

Updates the UI-enhanced tool result path for embedded notebooks by replacing the previous verbose, agent-facing URL marker with a compact <result uuid="...">…</result> wrapper that viewers can use to reconstruct the Wolfram Cloud notebook URL when _meta is dropped by the host.

Changes:

  • Wrap cloud notebook tool output in <result uuid="…">…</result> markers and add UUID extraction (cloudNotebookUUID) to support URL recovery.
  • Update the evaluator, Wolfram|Alpha, and notebook viewers to recover notebook URLs from the new marker and to strip the marker tags from displayed text.
  • Refresh documentation and tests to match the new marker format and session reminder text.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Tests/MCPApps.wlt Updates marker tests to validate <result uuid="..."> wrapping and adds a cloudNotebookUUID extraction test.
Kernel/UIResources.wl Implements result wrapping, UUID extraction, and configures cloud notebook deployment to return UUID-form URLs.
Kernel/Tools/WolframLanguageEvaluator.wl Updates UI-result comment and shortens the session reminder text format.
Kernel/Tools/WolframAlpha.wl Updates UI-result comment to reflect the new <result uuid> marker.
docs/mcp-apps.md Documents the new marker format and UUID-based URL recovery behavior.
Assets/Apps/wolframalpha-viewer.html Switches URL recovery/stripping logic from <internal><url> to <result uuid>.
Assets/Apps/notebook-viewer.html Switches URL recovery logic from <internal><url> to <result uuid>.
Assets/Apps/evaluator-viewer.html Switches URL recovery/stripping logic from <internal><url> to <result uuid>.

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

Comment thread Kernel/UIResources.wl
Comment thread Kernel/UIResources.wl
Comment thread Assets/Apps/evaluator-viewer.html
Comment thread Assets/Apps/evaluator-viewer.html
Comment thread Assets/Apps/wolframalpha-viewer.html
Comment thread Assets/Apps/wolframalpha-viewer.html
Comment thread Assets/Apps/notebook-viewer.html
@rhennigan rhennigan merged commit ac45683 into main Jul 9, 2026
1 of 2 checks passed
@rhennigan rhennigan deleted the feature/wl-output-cleanup branch July 9, 2026 20:09
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.

2 participants