Skip to content
Konstera
Docs · Build agents
Konstera documentation.

Getting started, SDK quickstart, manifest reference, kernel MCP services, deploy guide and FAQ — everything you need to build and run agents on Konstera.

Invocation modes

A Konstera agent handler fires on every invocation regardless of how it was triggered. Six triggers cover the real-world patterns:

ModeTriggerLatencyTypical use
Sync HTTPPOST /api/agents/{id}/invoke with ?stream=sse<1s–30sUser-facing requests, chat UI
AsyncPOST /api/agents/{id}/enqueue returns a workflow idpolled laterLong-running jobs, background work
Cronschedules[] in manifestfires on cronHourly polling, nightly batch
Webhookwebhooks[] in manifest + HMAC verification<1s3rd-party events (Stripe, Shopify)
Child workflowctx.agents.invoke() from another agentsync returnMulti-agent orchestration
Human signalctx.human.request() resumes on decisionpending until humanHITL approvals

How they differ at the kernel#

Every invocation becomes a Temporal workflow (ADR-002). The mode only changes the entry point:

Code
sync HTTP      → start workflow + stream SSE from activity
async          → start workflow + return workflowId
cron           → scheduled trigger starts workflow with cron's input payload
webhook        → HMAC-verified /wh/{slug} starts workflow with request body
child workflow → ctx.agents.invoke() creates a child workflow + awaits
human signal   → ctx.human.request() submits approval + awaits Temporal signal

Retries, timeouts, exponential backoff are Temporal activity policies driven by the manifest's retryPolicy. You don't write retry logic — Temporal replays activities that failed, your handler sees the same input on each attempt, and ctx.state + ctx.vector persist across replays.

Picking the right mode#

Sync HTTP#

Best when:

  • A user is waiting (chat, inbox reply draft)
  • Response time matters (< 30s typically)
  • The caller wants streaming (SSE for LLM-generated content)
Terminal
# Sync invocation with SSE streaming
curl -N -X POST \
  "https://api.konstera.ai/api/agents/io.konstera.hello/invoke?stream=sse" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"input": "Alice"}'

Response: a stream of SSE events. The last event: result carries the AgentResponse.

Async#

Best when:

  • The work takes longer than 30s
  • The caller can poll a workflow ID later
  • Multiple concurrent invocations should run in parallel
Terminal
# Enqueue, get back a workflow id
curl -X POST "https://api.konstera.ai/api/agents/io.konstera.batch/enqueue" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"payload": {"batch_id": "B-1234"}}'
# { "workflowId": "inv-9f3e..." }

# Later: poll
curl "https://api.konstera.ai/api/invocations/inv-9f3e..." -H "Authorization: Bearer $TOKEN"

Cron / scheduled#

Best when:

  • Hourly backlog polling, nightly batch, periodic health checks
  • No external trigger — the agent fires on wall-clock time

Declare in the manifest:

JSON
"schedules": [
  {
    "name": "hourly-backlog",
    "cron": "0 * * * *",
    "timezone": "UTC",
    "input": { "mode": "poll" }
  }
]

Scheduled invocations arrive at handle() with the entry's input as req.payload. See Cookbook: Scheduled cron agent for a complete recipe.

Webhook#

Best when:

  • A 3rd party pushes events (Stripe, Shopify, Zendesk)
  • You need to react within seconds of the event
  • The 3rd party signs the payload (HMAC) so you can verify authenticity

Declare in the manifest:

JSON
"webhooks": [
  {
    "name": "stripe-events",
    "path": "/webhooks/stripe-events",
    "hmac_secret_credential": "stripe-webhook-secret",
    "signature_header": "Stripe-Signature"
  }
]

Publicly exposed at https://api.konstera.ai/wh/{tenant-id}/webhooks/stripe-events. The kernel verifies the signature using the credential, then starts the workflow with the raw body as req.payload.

Child workflow (multi-agent)#

Best when:

  • One agent needs to call another's logic (not just data — if it's data, prefer ctx.state or a connector)
  • The call should be auditable + replayable as a separate invocation
Python
# Agent A calling Agent B
forecast = await ctx.agents.invoke(
    "io.konstera.demand-forecaster",
    input="Q4 forecast",
    payload={"sku": "SKU-123", "horizon_days": 30},
)
# forecast.content, forecast.structured

Each invoke() creates a child workflow with its own invocation ID and trace. See Cookbook: Multi-agent.

Human signal#

Best when:

  • An action needs reviewer approval
  • The agent can pause for seconds-to-days awaiting a decision
  • The reviewer uses the HITL inbox (not a webhook callback)

Covered in Cookbook: Human-in-the-loop with the full tier semantics (T0/T1/T2/T3).

What they share#

All six modes:

  • Hit the same handle(req, ctx) method — your code doesn't branch on "how was I invoked"
  • Produce the same invocation trace in the portal — observability is uniform
  • Count the same for cost + usage metering — one invocation is one unit regardless of trigger
  • Respect autonomy and require_review / require_approval — the trigger doesn't bypass the approval policy

The one small variation: req.payload shape depends on the trigger (cron sends the manifest's input; webhook sends the raw body; sync HTTP sends what the caller POSTed).

See also#