Skip to content

Add frontend tools implementation guide to HTTP API docs - #1867

Merged
aantn merged 5 commits into
masterfrom
claude/document-frontend-http-tools-j72Ld
Apr 1, 2026
Merged

aantn merged 5 commits into
masterfrom
claude/document-frontend-http-tools-j72Ld

Conversation

@aantn

@aantn aantn commented Apr 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Added comprehensive documentation for implementing frontend tools in client applications, including step-by-step examples and best practices. Also reordered the navigation to prioritize the HTTP API reference.

Key Changes

  • New implementation guide section: Added "Implementing Frontend Tools in Your Client" to the HTTP API documentation with 6 detailed steps covering:

    • Tool definition in requests
    • Streaming request setup
    • SSE stream parsing
    • Pause-mode tool call handling
    • Tool execution and stream resumption
    • Noop-mode (fire-and-forget) tool handling
  • Code examples: Included practical JavaScript examples for each step, demonstrating:

    • Tool definition with parameters and modes
    • SSE event parsing and dispatching
    • Event handler implementation
    • Tool execution and result submission
    • Stream resumption with conversation history
  • Implementation notes: Added critical guidance on:

    • Re-sending tool definitions on every request
    • Result serialization requirements (must be strings)
    • Conversation history handling for resumed streams
    • Mixed approval scenarios (both approvals and frontend tool calls)
    • Error handling patterns
  • Navigation reordering: Moved "HTTP API" to the top of the reference documentation navigation for better discoverability

Implementation Details

The guide follows a progressive learning approach, building from basic tool definition through advanced scenarios like mixed pause types and error handling. All examples use realistic use cases (chart rendering, page navigation) to illustrate concepts clearly.

https://claude.ai/code/session_013fd6r27uVfY2RijXoJhJs2

Summary by CodeRabbit

  • Documentation
    • Reordered reference navigation for clearer ordering.
    • Expanded HTTP API documentation with a new client guide for frontend tools: details the two-request pause/resume flow, batching and repeated pause-mode calls, noop-mode behavior, required client actions (resend tool list each request, include conversation history on resume, return tool results as JSON-encoded strings), and error/edge-case handling.

…eference nav

Add a step-by-step "Implementing Frontend Tools in Your Client" section
to the HTTP API docs covering tool definition, SSE stream parsing,
pause-mode resume flow, and noop-mode fire-and-forget handling with
JavaScript examples. Move HTTP API to first position in reference nav.

https://claude.ai/code/session_013fd6r27uVfY2RijXoJhJs2
Signed-off-by: Claude <noreply@anthropic.com>

@claude claude Bot 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.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Apr 1, 2026 •

Copy link
Copy Markdown
Contributor

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: 7a8d8ad8-df80-4cb7-bb62-da5dbfb5147c

📥 Commits

Reviewing files that changed from the base of the PR and between 5967826 and 45eb14a.

📒 Files selected for processing (1)
  • docs/reference/http-api.md
✅ Files skipped from review due to trivial changes (1)
  • docs/reference/http-api.md

Walkthrough

Reordered docs/reference/.nav.yml to place the HTTP API entry earlier in the navigation and expanded docs/reference/http-api.md with a detailed pause‑and‑resume two-request SSE flow for frontend pause-mode tools, multi-tool behavior, noop-mode notes, result/error encoding, and a client implementation guide.

Changes

Cohort / File(s) Summary
Navigation
docs/reference/.nav.yml
Moved the "HTTP API: http-api.md" entry higher in the reference navigation ordering.
HTTP API Documentation
docs/reference/http-api.md
Added a new "Implementing Frontend Tools in Your Client" section and expanded frontend tool semantics: two-request pause/resume SSE flow (initial POST streams approval_required with pending_frontend_tool_calls + conversation_history; follow-up POST resumes with frontend_tool_results and conversation_history), handling of multiple pause-mode calls, noop-mode behavior, requirement that frontend_tool_results[].result be a JSON-encoded string, mixed pending approvals handling, and error-return conventions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant FrontendToolExecutor

    rect rgba(100, 150, 255, 0.5)
    Note over Client,Server: Request 1: Initial /api/chat with frontend_tools
    Client->>Server: POST /api/chat (SSE stream)
    Server->>Server: Process chat, detect pause-mode tool calls
    Server-->>Client: Stream events including approval_required (pending_frontend_tool_calls + conversation_history)
    Server-->>Client: Stream ends
    end

    rect rgba(100, 200, 100, 0.5)
    Note over Client,FrontendToolExecutor: Client-side execution
    Client->>FrontendToolExecutor: Execute pending frontend tools
    FrontendToolExecutor-->>Client: Return frontend_tool_results (JSON-encoded strings)
    end

    rect rgba(255, 180, 100, 0.5)
    Note over Client,Server: Request 2: Resume /api/chat with results
    Client->>Server: POST /api/chat (SSE) with conversation_history + frontend_tool_results
    Server->>Server: Resume processing using provided tool results
    Server-->>Client: Stream remaining response
    end
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • arikalon1
  • moshemorad
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding a frontend tools implementation guide to HTTP API docs, which aligns with the primary documentation addition in http-api.md.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@netlify

netlify Bot commented Apr 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for holmes-docs ready!

Name Link
🔨 Latest commit 45eb14a
🔍 Latest deploy log https://app.netlify.com/projects/holmes-docs/deploys/69ccd95e843dd300085fe1d1
😎 Deploy Preview https://deploy-preview-1867--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.

claude added 2 commits April 1, 2026 08:24
…t guide

Replace hand-rolled ReadableStream + regex parsing with
@microsoft/fetch-event-source, which is what real projects use for
POST-based SSE endpoints. Consolidate steps 2+3 into one and update
the resume flow to reuse the streamChat helper.

https://claude.ai/code/session_013fd6r27uVfY2RijXoJhJs2
Signed-off-by: Claude <noreply@anthropic.com>
Add a numbered request-pause-resume explanation to the Frontend Tools
section showing that a single LLM turn is split across request 1
(stream until pause) and request 2 (resume with tool results). Update
the implementation guide headings and code comments to label which
request is which.

https://claude.ai/code/session_013fd6r27uVfY2RijXoJhJs2
Signed-off-by: Claude <noreply@anthropic.com>

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
docs/reference/http-api.md (1)

512-539: Consider clarifying the originalQuestion variable scope.

Line 534 references originalQuestion, but this variable is not defined in the function parameters or shown in scope. While this is example code, it might help to add a comment or parameter to clarify where this value should come from (e.g., stored from the initial request or passed as a parameter).

💡 Suggested clarification
-async function handleFrontendToolCalls(pendingCalls, conversationHistory) {
+async function handleFrontendToolCalls(pendingCalls, conversationHistory, originalQuestion) {
   const results = [];

   for (const call of pendingCalls) {

Or add a comment:

   // Request 2: resume the LLM with tool results
+  // originalQuestion should be saved from the initial request
   streamChat({
     ask: originalQuestion,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/reference/http-api.md` around lines 512 - 539, The example uses
originalQuestion inside handleFrontendToolCalls but originalQuestion is not
defined; update handleFrontendToolCalls to either accept originalQuestion as a
parameter (e.g., function handleFrontendToolCalls(pendingCalls,
conversationHistory, originalQuestion)) or add a clear inline comment above the
streamChat call explaining that originalQuestion must be captured from the
initial request scope and passed into this function, and ensure streamChat is
called with that passed-in value so references to originalQuestion (and the
streamChat call) are unambiguous.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/reference/http-api.md`:
- Around line 512-539: The example uses originalQuestion inside
handleFrontendToolCalls but originalQuestion is not defined; update
handleFrontendToolCalls to either accept originalQuestion as a parameter (e.g.,
function handleFrontendToolCalls(pendingCalls, conversationHistory,
originalQuestion)) or add a clear inline comment above the streamChat call
explaining that originalQuestion must be captured from the initial request scope
and passed into this function, and ensure streamChat is called with that
passed-in value so references to originalQuestion (and the streamChat call) are
unambiguous.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddc788ef-383f-4237-b77d-56c8b96506ab

📥 Commits

Reviewing files that changed from the base of the PR and between a142e15 and 2f1738e.

📒 Files selected for processing (2)
  • docs/reference/.nav.yml
  • docs/reference/http-api.md

claude added 2 commits April 1, 2026 08:32
'Turn' could mean a single LLM iteration or the full multi-iteration
request. Replaced with 'iteration' when referring to one LLM tool-call
cycle and 'request' when referring to the full HTTP request.

https://claude.ai/code/session_013fd6r27uVfY2RijXoJhJs2
Signed-off-by: Claude <noreply@anthropic.com>
@aantn
aantn enabled auto-merge (squash) April 1, 2026 08:46
@aantn
aantn merged commit 3f2ff0a into master Apr 1, 2026
15 of 16 checks passed
@aantn
aantn deleted the claude/document-frontend-http-tools-j72Ld branch April 1, 2026 08:50
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.

3 participants