Skip to content

feat(agent): exchange options and terms approval on firecrawl_agent - #453

Merged
rakshith48 merged 2 commits into
mainfrom
rak/agent-exchange-terms
Sep 28, 2026
Merged

rakshith48 merged 2 commits into
mainfrom
rak/agent-exchange-terms

Conversation

@rakshith48

@rakshith48 rakshith48 commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #446 (merged), which added threadId and mode. Together with #446, this replaces #445.

Why

With exchange.onTermsRequired: "ask", an agent turn can end on a terms offer: a pendingApproval with kind: "terms", plus exchange.requiresAction. Before this PR, an MCP caller could run terms/accept but couldn't answer the offer on the same thread.

What changed

  • firecrawl_agent takes exchange, a strict object that mirrors the gateway's agentExchangeSchema (firecrawl#4759). It is forwarded through the SDK's startAgent; firecrawl 4.40.0 passes exchange through as-is. The fields:
    • enabled
    • toolkits: at most 5, the agent service's limit
    • maxCalls: 1 to 30
    • requireApproval
    • approve: {approvalId, callIds?, always?}
    • decline: {approvalId}
    • onTermsRequired: "skip" | "ask"
  • Checks that reject a call before anything is sent:
    • approve or decline without threadId. Without a thread, the agent service silently ignores them.
    • approve and decline together. The agent service silently prefers approve.
    • requireApproval without mode: "chat" on the same request. The agent service checks the request's own mode, not the thread's inherited one, and the gateway turns its 400 into a 500.
  • The tool description covers:
    • skippedProviders and requiresAction.
    • The ask-mode flow: show the user the terms, get their EXPLICIT consent, run terms/accept through firecrawl_scrape, then call firecrawl_agent with the same threadId and exchange.approve: {approvalId}.
    • Declining: send exchange.decline: {approvalId}.
    • Never auto-accepting terms.
    • It stays under CLAUDE_CODE_TEXT_CAP.
  • firecrawl_agent_status keeps exchange and pendingApproval in its structured content, in both the terms and the paid-call shape.
  • README (exchange arguments, the 4-step terms flow, an approve example) and CHANGELOG updated.

Tests

  • New tests cover:
    • Schema parity with the gateway.
    • Exact request bodies for approve, decline, a paid-call approve and onTermsRequired.
    • Rejected inputs, with a check that none of them reach the API.
    • Status output for both pendingApproval shapes.
  • Results: npm test 126/126 pass, tsc clean, eslint clean on the changed files (rebased onto main after feat(agent): continue a thread from firecrawl_agent #446 merged).

Known gaps

  • Answer errors come back as a generic 500. A stale approvalId (approval_stale, 409) is rejected by the agent service after the gateway passes the request through, and the gateway returns 500 "Failed to passthrough agent request.".
  • A prompt is required on approve/decline turns. MCP keeps prompt at min(1), so callers send a short message such as "I accepted the terms. Continue."

🤖 Generated with Claude Code

@rakshith48
rakshith48 marked this pull request as ready for review September 26, 2026 16:04

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread tests/mcp-smoke.test.mjs Outdated

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Adds exchange to firecrawl_agent to answer pending terms/paid-call approvals on the same thread, with tests and docs. It changes the MCP tool's public request/response shape and adds a terms/paid-call approval flow, so human sign-off is needed.

Re-trigger cubic

rakshith48 and others added 2 commits September 27, 2026 22:50
firecrawl_agent takes an exchange object that mirrors the gateway's
agentExchangeSchema (enabled, toolkits (max 5), maxCalls, requireApproval,
approve, decline, onTermsRequired), forwarded through the SDK's startAgent.
Pre-send checks: approve/decline need threadId and cannot be sent together;
requireApproval needs mode "chat" on the same request. The tool description
gives the ask-mode terms flow (show the terms, explicit consent, terms/accept,
continue with exchange.approve), and firecrawl_agent_status keeps exchange
and pendingApproval in its structured content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…; assert the turn's thread

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rakshith48
rakshith48 force-pushed the rak/agent-exchange-terms branch from 7ef8805 to 9f3805e Compare September 27, 2026 12:50
@rakshith48
rakshith48 changed the base branch from rak/agent-thread-continue to main September 27, 2026 12:50
@rakshith48
rakshith48 merged commit dfab33f into main Sep 28, 2026
1 check passed
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