Skip to content

feat(sdk): cloud endpoints, API executor, and Communicate SDK v2 protocol#632

Merged
khaliqgant merged 8 commits intomainfrom
cloud-endpoints
Mar 24, 2026
Merged

feat(sdk): cloud endpoints, API executor, and Communicate SDK v2 protocol#632
khaliqgant merged 8 commits intomainfrom
cloud-endpoints

Conversation

@khaliqgant
Copy link
Member

@khaliqgant khaliqgant commented Mar 24, 2026

Summary

Major SDK update that adds cloud workflow execution, a direct API executor for LLM calls, and migrates the Communicate SDK to the v2 REST/WebSocket protocol.

Cloud Workflow Execution

  • cloud-runner.ts — Submit workflows to AgentWorkforce Cloud API and poll for completion. Enabled via .run({ cloud: true }) on the workflow builder.
  • CloudRunOptions — Configurable API URL, auth token, env secrets forwarding, poll interval, and status change callbacks.
  • Builder integrationWorkflowBuilder.run() now accepts cloud, cloudApiUrl, cloudApiToken, envSecrets, cloudPollIntervalMs, and onCloudStatusChange options.

API Executor (cli: api)

  • api-executor.ts — Direct LLM API calls via fetch (Anthropic, OpenAI, Google) without spawning CLI processes or sandboxes.
  • New AgentCli value: "api" — Agents with cli: "api" execute steps via direct API calls instead of PTY/subprocess.
  • Provider auto-detection from model name prefix (claude-* → Anthropic, gpt-*/o1-*/o3-*/o4-* → OpenAI, gemini-* → Google).
  • Skills supportskills field on agent definitions passes system prompts to API-mode agents.
  • Runner integrationexecuteAgentStep detects cli: "api" and routes through executeApiStep instead of the CLI spawn path.

Communicate SDK v2 Protocol Migration

Migrated all HTTP endpoints and WebSocket paths to the v2 protocol:

Operation Old (v1) New (v2)
Register agent POST /v1/agents POST /v1/agents/register
Unregister agent POST /v1/agents/disconnect DELETE /v1/agents/{id}
Send DM POST /v1/dm POST /v1/messages/dm
Post to channel POST /v1/channels/{ch}/messages POST /v1/messages/channel
Reply to message POST /v1/messages/{id}/replies POST /v1/messages/reply
Check inbox GET /v1/inbox GET /v1/inbox/{agentId}
WebSocket /v1/ws?token=... /v1/ws/{agentId}?token=...

Auth simplification: Removed per-agent token auth (sendHttpAsAgent). All endpoints now use workspace API key auth. Agent identity is passed in request bodies (from field) and URL paths.

Message parsing simplification: Removed multi-format message extraction (nested .data, .message wrappers, multiple event types). Now expects flat response shapes ({ message_id }, { messages }, { agents }).

WebSocket events: Simplified from multiple event types (message.created, dm.received, direct_message.received, thread.reply, group_dm.received) to single message type.

Channel Management

  • New unit tests (channel-management.test.ts, relay-channel-ops.test.ts) — subscribe, unsubscribe, mute, unmute protocol messages and state updates.
  • Integration test (tests/integration/broker/channel-management.test.ts) — Full broker flow: spawn agent → subscribe → mute → verify no delivery → unmute → verify delivery → unsubscribe.

Other Changes

  • Codex bypass flagnonInteractiveArgs for Codex now includes --dangerously-bypass-approvals-and-sandbox in the command args (not just as metadata).
  • Pi adapter cleanup — Removed cleanup() method from onPiRelay return type.
  • Adapter pruning — Removed adapters for CrewAI, OpenAI Agents, LangGraph, Google ADK, and AI SDK. Only Pi and Claude SDK adapters remain.
  • onRelay / withRelay auto-detect — New unified entry point that auto-detects Pi vs Claude SDK framework from config shape.
  • envSecrets plumbed through WorkflowRunnerOptionsWorkflowRunnerexecuteApiStep.

Test Plan

  • Unit tests for channel management protocol messages
  • Unit tests for AgentRelay channel operations (subscribe, mute, unmute)
  • Updated buildNonInteractiveCommand test for Codex bypass flag
  • Integration test for broker channel management flow
  • Transport tests updated for v2 protocol endpoints
  • Communicate core tests updated for v2 protocol

Open with Devin

Two new SDK features:

1. cli: 'api' — direct provider API calls via fetch()
   - Anthropic, OpenAI, Google supported (detected from model name)
   - skills field → system prompt per agent
   - No sandbox, no CLI, instant execution

2. cloud: true — run workflows in cloud sandboxes
   - Submit via cloud API, poll for results
   - Same WorkflowRunRow shape as local execution
   - envSecrets for secure API key injection

Usage:
  .agent('worker', { cli: 'api', model: 'claude-sonnet-4-20250514', skills: '...' })
  .run({ cloud: true, envSecrets: { ANTHROPIC_API_KEY: '...' } })
@khaliqgant khaliqgant changed the title Cloud endpoints feat(sdk): cloud endpoints, API executor, and Communicate SDK v2 protocol Mar 24, 2026
AgentCli type includes 'api' but CLI_REGISTRY (Record<AgentCli, ...>)
was missing the entry, causing tsc build failure.
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +3225 to +3257
if (specialistDef.cli === 'api') {
const stepOutputContext = this.buildStepOutputContext(stepStates, runId);
const resolvedTask = this.interpolateStepTask(step.task ?? '', stepOutputContext);

state.row.status = 'running';
state.row.startedAt = new Date().toISOString();
await this.db.updateStep(state.row.id, {
status: 'running',
startedAt: state.row.startedAt,
updatedAt: new Date().toISOString(),
});
this.emit({ type: 'step:started', runId, stepName: step.name });
this.postToChannel(`**[${step.name}]** Started (api)`);

const output = await executeApiStep(
specialistDef.constraints?.model ?? 'claude-sonnet-4-20250514',
resolvedTask,
{ envSecrets: this.envSecrets, skills: specialistDef.skills },
);

state.row.status = 'completed';
state.row.output = output;
state.row.completedAt = new Date().toISOString();
await this.db.updateStep(state.row.id, {
status: 'completed',
output,
completedAt: state.row.completedAt,
updatedAt: new Date().toISOString(),
});
await this.persistStepOutput(runId, step.name, output);
this.emit({ type: 'step:completed', runId, stepName: step.name, output });
return;
}
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 API-mode agents completely bypass the retry loop

The API-mode agent path (cli === 'api') at packages/sdk/src/workflows/runner.ts:3225 returns early before the retry for loop at line 3316. This means step.retries, specialistDef.constraints?.retries, and errorHandling?.maxRetries are all silently ignored for API-mode agents. Any transient failure (rate limits, network errors) causes immediate step failure, even when the workflow is configured with retry policies. This is particularly problematic because LLM API calls are commonly rate-limited and the workflow's default error handling config (builder.ts:357-361) defaults to strategy: 'retry', maxRetries: 2.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Wraps executeApiStep in try/catch so failures properly:
- Update step DB record to 'failed' with error message
- Emit step:failed event
- Post failure to channel
- Re-throw so workflow DAG handles it correctly

Previously, API errors left the step stuck in 'running' state.
devin-ai-integration[bot]

This comment was marked as resolved.

1. Pass specialistDef.constraints.maxTokens through to executeApiStep
   as defaultMaxTokens (was silently ignored).

2. Google API: use x-goog-api-key header instead of URL query param.
   Prevents key leakage in server logs, proxies, and error messages.
devin-ai-integration[bot]

This comment was marked as resolved.

Throws early with clear error instead of returning undefined cmd.
Also checks binaries.length for safety.
devin-ai-integration[bot]

This comment was marked as resolved.

khaliqgant and others added 2 commits March 24, 2026 15:15
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@khaliqgant khaliqgant merged commit b2f889a into main Mar 24, 2026
34 checks passed
@khaliqgant khaliqgant deleted the cloud-endpoints branch March 24, 2026 14:41
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