Skip to main content

Definition

Capability fields (tools, llm, http, stream) are always non-None. They default to safe stubs that raise RuntimeError if called outside the host environment.

Fields

env

  • Type: dict[str, str]
  • Description: Environment variables configured via the @agent decorator’s environment field.
Populated from Friday’s environment matching environment.required and environment.optional configuration.

config

  • Type: dict
  • Description: Agent-specific configuration and space context.
May include:
  • platformUrl - Friday API base URL
  • skills - List of space skills for the session
  • workDir - Existing space directory (if FSM set one up)
  • Custom fields passed by the orchestrator

session

  • Type: SessionData | None
  • Description: Session metadata when running within a Friday session.
May be None in test contexts or standalone execution.

output_schema

  • Type: dict | None
  • Description: JSON Schema for structured output, if specified by the caller.

tools

  • Type: Tools
  • Description: MCP tool capability wrapper. Always available - returns empty list when no MCP servers configured.
Methods:
  • ctx.tools.list()list[ToolDefinition]
  • ctx.tools.call(name, args)dict
See ctx.tools.

llm

  • Type: Llm
  • Description: LLM capability wrapper for generation calls. Always available in host environment.
Methods:
  • ctx.llm.generate(messages, model, ...)LlmResponse
  • ctx.llm.generate_object(messages, schema, ...)LlmResponse
See ctx.llm.

http

  • Type: Http
  • Description: HTTP capability wrapper for outbound requests. Always available in host environment.
Methods:
  • ctx.http.fetch(url, method, headers, body, timeout_ms)HttpResponse
See ctx.http.

stream

  • Type: StreamEmitter
  • Description: Stream capability for progress emission. Always available in host environment.
Methods:
  • ctx.stream.progress(content, tool_name)
  • ctx.stream.intent(content)
  • ctx.stream.emit(event_type, data)
See ctx.stream.

Availability Guarantees

Defensive Programming

Test contexts: When running outside Friday (unit tests), calling capabilities raises RuntimeError with a clear message. To test agents properly, mock the capabilities or run against a local Friday daemon.

Context Round-Trip

All context fields are serialized over NATS for each invocation:
  1. Friday serializes context as JSON
  2. JSON is sent to the agent subprocess via NATS
  3. SDK bridge deserializes to AgentContext dataclass
  4. Your code uses the context
  5. Result serializes back to the host
The context-inspector example agent demonstrates all fields survive this round-trip correctly.

See Also

ctx.llm

LLM generation

ctx.http

HTTP requests

ctx.tools

MCP tool calls

ctx.stream

Progress streaming

Result Types

ok() and err() return values