Invocations
An invocation is a single request-response cycle with an agent.What is an Invocation?
When you run:- The prompt you sent
- The response you received
- Tokens used and cost
- Execution time
- Status (completed, failed)
Invocation Flow
- Request — You send a prompt via CLI, SDK, or API
- Routing — Castari routes to your agent’s sandbox
- Execution — Agent processes prompt, uses tools, generates response
- Response — Output captured and returned to you
- Tracking — Tokens, cost, and duration recorded
Input and Output
Input
Your prompt is passed to the agent via stdin:Output
Agent response is written to stdout:Only stdout is captured as the response. stderr is logged but not returned.
Invocation Result
Every invocation returns:| Field | Description |
|---|---|
invocation_id | Unique identifier |
session_id | Session identifier |
response_content | Agent’s output |
input_tokens | Tokens in the prompt |
output_tokens | Tokens in the response |
total_cost_usd | Total cost in USD |
duration_ms | Execution time |
status | completed or failed |
Statuses
| Status | Description |
|---|---|
completed | Agent finished successfully |
failed | Agent encountered an error |
Timeouts
Default timeout is 120 seconds (2 minutes). Maximum timeout: 600 seconds (10 minutes). Timeouts result in afailed status with an appropriate error message.
Cost Tracking
Costs are calculated based on:- Input tokens — Prompt + system instructions
- Output tokens — Agent’s response
- Model — Claude pricing tiers
Concurrency
Multiple invocations can run in parallel:Error Handling
In CLI
In SDK
See Also
cast invoke
CLI reference
Agents API
SDK reference
Debugging
Troubleshooting tips