Skip to content

feat(agent): continue a thread from firecrawl_agent - #446

Merged
rakshith48 merged 8 commits into
mainfrom
rak/agent-thread-continue
Sep 27, 2026
Merged

rakshith48 merged 8 commits into
mainfrom
rak/agent-thread-continue

Conversation

@rakshith48

@rakshith48 rakshith48 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Split into two PRs. This PR covers thread continuation. The exchange options and terms approve/decline are in the stacked #453. Together they replace #445, which can be closed as superseded.

Why

The Firecrawl Agent supports threads (threadId, mode), but firecrawl_agent couldn't continue one. Every call started a new thread.

What changed

  • firecrawl_agent accepts:
    • threadId (uuid): continue an existing thread.
    • mode: "extract" or "chat".
    • Both are forwarded through the SDK's startAgent; firecrawl 4.40.0 forwards threadId and mode. On a follow-up, omitted mode, urls and schema carry over from the previous turn.
  • No model parameter. The gateway runs every request on spark-2, which threads need.
  • The tool description says how to continue a thread, and stays under CLAUDE_CODE_TEXT_CAP.
  • firecrawl_agent_status structured content keeps message (the reply to a follow-up in chat mode) and suggestions, next to the existing threadId, threadTurn and mode.
  • README:
    • The new threadId / mode arguments and a follow-up example.
    • The missing effort, maxCredits (API default 2,500) and strictConstrainToURLs bullets.
  • CHANGELOG updated.

Tests

  • New test: firecrawl_agent continues a thread. It covers:
    • The input schema.
    • Exact request bodies for a follow-up and an inherited-mode turn, with no model sent.
    • Rejected threadId / mode values, with a check that nothing is sent.
    • A 409 thread-busy error reaching the caller.
    • Status structured output.
  • The description-length check uses CLAUDE_CODE_TEXT_CAP.
  • Results: npm test 124/124 pass, tsc clean, eslint clean on the changed files. npm run lint still reports one error in src/alexandria.ts:97; it's already on main and not touched here.

Known limitation

A follow-up can't clear an inherited urls or schema. The agent service clears them with urls: [] or schema: null, but MCP drops empty and null values, and the SDK drops a null schema. Left out for now to stay on the SDK.

🤖 Generated with Claude Code

rakshith48 and others added 5 commits September 27, 2026 01:40
The agent service now only calls Alexandria providers whose data terms the
team has accepted, and reports the rest. Let MCP callers choose what
happens ("skip", "ask" or "fail"), forwarded as exchange.onTermsRequired.

Describe exchange.skippedProviders and exchange.requiresAction in the tool
description, and tell calling agents they must get the user's explicit
consent before calling terms/accept. Keep exchange, pendingApproval and
message in firecrawl_agent_status structured content so Codex-style
clients that read structuredContent do not lose them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the extract-v3#182 scope cut: onTermsRequired is skip or ask, and
exchange.error is gone. Describe each requiresAction provider digest as
string | null and always present.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r sends

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ecrawl_agent

firecrawl_agent now takes threadId, mode and an exchange object that mirrors
the gateway's agentExchangeSchema (enabled, toolkits, maxCalls,
requireApproval, approve, decline, onTermsRequired). After an ask-mode terms
offer and the user's explicit consent to terms/accept, a caller continues the
same thread with exchange.approve: {approvalId} (or decline) instead of
starting over.

MCP-side guards: approve/decline need threadId, cannot be sent together, and
the top-level onTermsRequired cannot disagree with exchange.onTermsRequired.
Status structured content also keeps suggestions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the top-level onTermsRequired shorthand and its merge logic; callers set
exchange.onTermsRequired, exactly as the gateway's agentExchangeSchema defines
it. Nothing has been released with the shorthand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rakshith48
rakshith48 force-pushed the rak/agent-thread-continue branch from cdc04ca to 402264f Compare September 26, 2026 15:42
@rakshith48 rakshith48 changed the title feat(agent): continue a thread and answer pending approvals from firecrawl_agent feat(agent): threads, pending approvals and onTermsRequired for firecrawl_agent (replaces #445) Sep 26, 2026
@rakshith48
rakshith48 changed the base branch from rak/agent-on-terms-required to main September 26, 2026 15:43
@rakshith48
rakshith48 marked this pull request as ready for review September 26, 2026 15:44

@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

Re-trigger cubic

Comment thread src/index.ts
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread README.md Outdated
Comment thread tests/mcp-smoke.test.mjs Outdated
rakshith48 and others added 2 commits September 27, 2026 01:53
- On a follow-up, send `urls: []` and `schema: null` (or `{}`) so they clear
  what the thread inherits. POST /v2/agent directly because the SDK's
  startAgent drops a null schema; errors are reported the same way.
- `exchange.toolkits` takes at most 5 slugs, the agent service's limit.
- `exchange.requireApproval` needs `mode: "chat"` on the same request: the
  agent service checks the request's mode, not the inherited one, and the
  gateway turns its 400 into a 500.
- README lists effort, maxCredits (API default 2,500) and
  strictConstrainToURLs; the description-length test uses
  CLAUDE_CODE_TEXT_CAP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…clears

The SDK drops a null schema, so clearing inherited urls/schema can't go
through it. Keep today's behaviour: empty or null values are dropped and the
thread's values are inherited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 4 files (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 thread continuation and approve/decline/onTermsRequired handling to firecrawl_agent, widening the public MCP tool contract and adding terms/paid-call approval flows; the contract and approval-policy choices are the decisive factors.

Re-trigger cubic

Move the exchange options, approve/decline checks, terms-flow text and the
pendingApproval/exchange status fields to a stacked PR. This PR keeps
threadId and mode on firecrawl_agent (forwarded through the SDK), message and
suggestions in the status output, the README arguments for effort,
maxCredits and strictConstrainToURLs, and the CLAUDE_CODE_TEXT_CAP test fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rakshith48 rakshith48 changed the title feat(agent): threads, pending approvals and onTermsRequired for firecrawl_agent (replaces #445) feat(agent): continue a thread from firecrawl_agent Sep 26, 2026

@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 (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread src/tool-output.ts
@rakshith48
rakshith48 merged commit f9ee82c into main Sep 27, 2026
2 checks 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.

1 participant