Skip to content

feat: Shorten task ID to <tool-name>-<12-char-suffix>#725

Draft
jirispilka wants to merge 1 commit intomasterfrom
claude/review-issue-705-jXqdU
Draft

feat: Shorten task ID to <tool-name>-<12-char-suffix>#725
jirispilka wants to merge 1 commit intomasterfrom
claude/review-issue-705-jXqdU

Conversation

@jirispilka
Copy link
Copy Markdown
Collaborator

Closes #705.

Summary

  • Task IDs were long and noisy — call-tool-apify--rag-web-browser-550e8400-e29b-41d4-a716-446655440000 (~70 chars).
  • New form: ${tool.name}-${randomBytes(9).toString('base64url')}apify--rag-web-browser-x7kQ9mZpA1bC (~35 chars).
  • Uses Node built-in randomBytes; no new dependency (avoids pulling nanoid for one call).
  • Uses tool.name (canonical, slash-safe) rather than raw request name (which can be the legacy apify-slash-… form).

MCP spec compliance

  • taskId MUST be a string — ✓
  • MUST be unique — ✓ (prefix + 72-bit random suffix; session-scoped taskStore)
  • MUST be receiver-generated — ✓
  • Entropy: 72 bits, plus the spec's preferred auth-context binding via mcpSessionId (see src/mcp/server.ts:543).

Spec ref: https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks

Changes

  • src/mcp/server.ts — swap randomUUID import for randomBytes; replace the task-ID expression.
  • res/mcp_task_reference.md — update stale // 32 hex chars comment.
  • tests/integration/suite.ts — add format assertion to the existing task-flow test.

Test plan

  • npm run type-check — passes
  • npm run lint — passes
  • npm run test:unit (515/515) — passes
  • npm run test:integration — requires APIFY_TOKEN; task-flow suite includes a new format assertion
  • mcpc probe: tools-call <actor> task:='{"ttl":60000}' <args> → inspect taskCreated.taskId shape
  • Non-task path: tools-call <actor> <args> returns unchanged CallToolResult (regression check)

https://claude.ai/code/session_012N7gXd5tWLp9Xic5JDVif9

Replace the long call-tool-<name>-<UUID> task ID (~70 chars) with a
short <tool.name>-<12 base64url chars> form. Uses randomBytes(9) from
node:crypto — no new dependency.

MCP spec compliant: taskId stays a unique string, and the 72-bit
random suffix combined with session-scoped taskStore binding meets
the entropy guidance (see res/mcp_task_reference.md).

Also adds a format assertion in the existing task integration test
and updates the stale "32 hex chars" comment in the task reference.

https://claude.ai/code/session_012N7gXd5tWLp9Xic5JDVif9
@github-actions github-actions Bot added the t-ai Issues owned by the AI team. label Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Use shorter and more useful Task ID

3 participants