Agentspan Worker Types

Workers are functions registered as Conductor task pollers. They execute locally (SDK-side) while execution orchestration happens server-side. Both Python and TypeScript SDKs implement all worker types with identical behavior.

Quick Reference

#Worker TypeTask Name PatternTrigger
1Tool{tool_name}agent.tools with tool_type == "worker"
2CLI Command{agent_name}_run_commandagent.cli_commands == True
3Code Execution{agent_name}_execute_codeagent.local_code_execution == True
4Output Guardrail (combined){agent_name}_output_guardrailCustom guardrails (local compile path)
5Individual Guardrail{guardrail.name}Custom guardrails (server compile path)
6Stop When{agent_name}_stop_whenagent.stop_when is callable
7Gate{agent_name}_gateagent.gate is callable
8Callback{agent_name}_{position}agent.callbacks
9Termination{agent_name}_terminationagent.termination is set
10Check Transfer{agent_name}_check_transferHybrid or swarm agent
11Router Function{agent_name}_router_fnstrategy == "router" with callable router
12Handoff Check{agent_name}_handoff_checkagent.handoffs is non-empty
13Swarm Transfer{source_agent}_transfer_to_{peer}strategy == "swarm" with sub-agents
14Manual Selection{agent_name}_process_selectionstrategy == "manual" with sub-agents
15Framework{worker.name}Foreign framework with extractable tools
16Framework Passthrough{worker_name}Foreign framework (passthrough)
17Claude Code Passthrough{agent_name}model="claude-code/..."

Task Definition Registration

Task definitions are registered by the server during agent compilation. SDKs do NOT register task definitions — they only poll for tasks. The server returns requiredWorkers in the start/deploy response so SDKs know exactly which workers to register.

SettingValueSource
timeoutSeconds0 (no timeout)AgentService.registerTaskDef()
responseTimeoutSeconds3600 (1 hour)Conductor requires minimum 1s
Retry count2Server-side
Retry logicLINEAR_BACKOFFServer-side
Retry delay2 sServer-side

Task Name Prefixing Rules

All auto-generated task names MUST be prefixed with the agent name to prevent collisions when multiple agents share the same Conductor namespace.

CategoryPatternExample
System workers{agentName}_{type}my_agent_termination
CLI tools{agentName}_run_commandgit_fetch_run_command
Code execution{agentName}_execute_codecoder_execute_code
Swarm transfers{sourceAgent}_transfer_to_{peer}coder_transfer_to_qa_tester
User-defined tools{tool_name} (user-controlled)get_weather

Credentials

Credentials are always resolved from the server. There is no environment variable fallback.

  • Execution token presentPOST /api/credentials/resolve → injected into process.env/os.environ
  • No execution tokenFAILED_WITH_TERMINAL_ERROR (non-retryable)
  • Credentials not found on serverFAILED_WITH_TERMINAL_ERROR (non-retryable)
  • Cleanup → credentials removed from environment after tool execution

Store credentials with: agentspan credentials set --name <NAME>

TypeScript Parity

Both Python and TypeScript SDKs implement all 17 worker types. The TypeScript SDK includes:

  • All SWARM workers (transfer_to, check_transfer, handoff_check, process_selection)
  • Claude Code agent support (ClaudeCode class, PermissionMode enum)
  • CLI command execution (CliConfig, makeCliTool())
  • Code execution validators (CommandValidator)
  • LLM guardrails (LLMGuardrail class)
  • Credential resolution and injection (resolveCredentials, injectCredentials)

Worker Lifecycle

  1. Server compilation — Server compiles agent → registers all task definitions → returns requiredWorkers list
  2. SDK registration — SDK registers workers (poll functions) for task names in requiredWorkers
  3. Polling — Workers poll Conductor for tasks, execute functions, report results
  4. Credentials — Before tool execution, credentials are resolved from server and injected
  5. Monitoring — TaskHandler checks process health every 5s and restarts dead workers
  6. Shutdown — Workers stopped during AgentRuntime.shutdown()