Skip to content
Konstera
Docs · Run & debug
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.

Debugging failed invocations

How to diagnose a failing invocation from the portal trace, how to replay it against a fix, and the top patterns that cause silent failures.

FlowThe debugging loop: every invocation leaves a trace you can replay against a fix Interactive — click a block

The invocation trace view#

Every invocation produces a trace. In the portal:

Agent → Overview: quality and value over 30 days, plus recent runs — click a run to open its full trace · example data
  1. Open the instance
    Instance → Invocations tab.
  2. Open the trace
    Click any row to open the trace.
  3. Read it top to bottom
    The trace shows each section below, chronologically.
Trace sectionWhat it shows
RequestinvocationId, input, payload, config
Kernel callsevery ctx.* call with args, result, latency, cost
LLM callsfull prompt + response + token counts + model + cost
Capability callscanonical name, resolved connector, request/response
Reviewer actions (if HITL)who acted, decision, decision reason
Exception (if raised)type, message, stack trace, line numbers

Everything in the trace is retained per the tenant's retention policy (default 90 days).

Three debugging recipes#

Start from the symptom:

SymptomLook first atUsual culprit
Wrong answerThe trace's LLM callPrompting / grounding, not a bug
Raised an exceptionThe trace's Exception sectionMissing await, unguarded optional capability, missing null-check
Silently did nothingInvocation count, kernel calls, instance statusUpstream trigger, direct-run no-ops, disabled instance

"The agent returned the wrong answer"#

Likely a prompting / grounding issue, not a bug. Check the trace's LLM call:

  1. Was the right context included? Common cause: ctx.vector.query() returned 0 hits (empty index? wrong namespace?) and the LLM answered without grounding.
  2. Was the prompt what you expected? The trace shows the full system + user strings. Easy to spot f-string formatting bugs where a variable was None and the literal "None" ended up in the prompt.
  3. Did temperature affect it? For deterministic tasks, set temperature=0.0 in ctx.llm.complete().

"The agent raised an exception"#

Check the trace's Exception section:

  1. Type + message: often tells you the fix inline. See Error catalog for the catalogue of common exceptions.
  2. Last successful kernel call: tells you where in handle() it got.
  3. Line numbers: map back to your source. Common causes:
    • Missing await on a ctx.* call (the coroutine is treated as truthy; subsequent code accesses attributes on the coroutine)
    • Unguarded optional capability (CapabilityUnbound)
    • Null-check missing on a kernel service that can return None (e.g. ctx.semantic.* returning None when the Context Service is disabled)

"The agent silently did nothing"#

Nothing in the inbox, no exception, no visible change. Three places to look:

  1. Was handle() actually called? Check the invocation count. If zero, the issue is upstream — maybe the webhook HMAC failed, or the schedule isn't firing (check the schedules tab in the portal).
  2. Did a kernel call fail silently? Fire-and-forget services (ctx.log.*, ctx.cost.record) can silently no-op in direct-run mode. If you're testing locally and never see logs — check KONSTERA_KERNEL_MCP_URL is set.
  3. Was the agent in a disabled instance? Instance in state disabled (ADR-006) still accepts /invoke calls but the kernel returns a specific error. Check instance status in the portal.

Replay for root-cause analysis#

The killer feature. From the invocation trace:

  1. Click Replay
    From the invocation trace.
  2. Choose a target
    Current version, previous version, or a draft agent.
  3. Click Run
    The same input is sent to the version you chose.

Replay sends the exact same input (req payload) to the chosen agent version. All kernel-side side effects are replayed from the original invocation's trace — the same LLM response is returned, the same vector hits, the same capability results. So you're testing your handler's reaction to the same inputs, not re-running the LLM.

SequenceReplay re-runs your handler; kernel results come from the original trace
PortalAgent versionOriginal trace1same req payload2ctx.* callsLLM response, vector hits, capability results3recorded results4your handler's reaction
Validate a fix

Deploy a draft agent with the fix, replay the failing invocation against the draft, see if it works.

A/B two versions

Compare two versions on the same real-world input.

Reproduce locally

konstera invocation replay <id> in CLI pulls the trace and runs it against a local-dev agent container.

Top five silent-failure patterns#

Check your agent for these before you ship
  • await on every ctx.* call — especially ctx.capability.available(...)
  • purpose= instead of a hard-coded model=
  • ctx.capability.call(...) instead of vendor SDK imports
  • Log that you fetched a credential, never its value
  • Keep capabilities.needs[] minimal

1. Missing await on a ctx.* call#

Python
# BUG:
if ctx.capability.available("orders.lookup_by_id"):  # coroutine is truthy!
    order = await ctx.capability.call("orders.lookup_by_id", id=oid)

# FIX:
if await ctx.capability.available("orders.lookup_by_id"):
    order = await ctx.capability.call("orders.lookup_by_id", id=oid)

2. Hard-coded model= across tenants#

Python
# BAD: tenant admin can't swap provider without a redeploy
result = await ctx.llm.complete(model="claude-sonnet-4-6", prompt=user_q)

# GOOD: use purpose; tenant binds it in the portal
result = await ctx.llm.complete(purpose="narrator", prompt=user_q)

3. Vendor SDK imports#

Python
# BAD: tightly couples the agent to Shopify
import shopify
orders = shopify.Order.find(email=customer.email)

# GOOD: capability indirection — works with any connector the tenant binds
orders = await ctx.capability.call("orders.lookup_by_email", email=customer.email)

See the capability catalogue for every canonical name an agent can call — one stable key per purpose, swappable connectors behind each.

4. Logging secrets#

Python
# BAD: credential value lands in the audit log
stripe_key = await ctx.credentials.get("stripe-api-key")
await ctx.log.info("got key", key=stripe_key)  # NO

# GOOD: log that you fetched the key, not the key
await ctx.log.info("stripe key fetched")

5. Over-declared capabilities.needs[]#

Do
  • Keep needs[] minimal — only what the agent actually uses.
  • Add a capability via a new version when a feature actually needs it.
Avoid
  • Over-declare "just in case". The manifest's needs[] is a permission list — anything listed may be checked by compliance tooling, and over-declaring blurs the agent's actual capability footprint.

See also#