agents.metrics-step-close ​
Close a step metric row with token counts and latency
Finalise a step metric row with token counts, latency, and finish reason.
Overview ​
| Property | Value |
|---|---|
| Workflow type | Linear |
| Library | App-agents |
| Version | 1.0 |
Triggers ​
| Source | Endpoint / Event | Description |
|---|---|---|
| INTERNAL | internal.invocation | Internal — called by the runner agent to record execution metrics |
Input Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
step_metric_uuid | string | No | — | — |
session_uuid | string | No | — | — |
organization_uuid | string | No | — | — |
step_number | integer | No | — | — |
turn | integer | No | — | — |
tokens_prompt | integer | No | — | — |
tokens_completion | integer | No | — | — |
tokens_cache_read | integer | No | — | — |
tokens_cache_write | integer | No | — | — |
tokens_reasoning | integer | No | — | — |
model_name | string | No | — | — |
finish_reason | string | No | — | — |
latency_ms | integer | No | — | — |
error | string | No | — | — |
cached_completion | string | No | — | — |
cached_output | dict | No | — | — |
Output Schema ​
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
error | string | No | — | — |
error_type | string | No | — | — |
failed_at | string | No | — | — |
failed_at_state | string | No | — | — |
failed_layer | json | No | — | — |
failed_step | string | No | — | — |
failure_reason | string | No | — | — |
finished_at | json | No | — | — |
step_metric_uuid | json | No | — | — |
session_uuid | json | No | — | — |
organization_uuid | json | No | — | — |
step_number | json | No | — | — |
turn | json | No | — | — |
tokens_prompt | json | No | — | — |
tokens_completion | json | No | — | — |
tokens_cache_read | json | No | — | — |
tokens_cache_write | json | No | — | — |
tokens_reasoning | json | No | — | — |
model_name | json | No | — | — |
finish_reason | json | No | — | — |
latency_ms | json | No | — | — |
cached_completion | json | No | — | — |
cached_output | json | No | — | — |
States ​
| State | Initial | Terminal | Success | Auto-advance | Description |
|---|---|---|---|---|---|
initiated | Yes | No | — | run | — |
run | No | No | — | complete | — |
completed | No | Yes | Yes | — | — |
failed | No | Yes | No | — | — |
State Diagram ​
Transitions ​
| From | Action | To | Description |
|---|---|---|---|
initiated | run | run | — |
run | complete | completed | — |
* (any state) | fail | failed | — |
API Usage ​
bash
POST /api/workflows/start
Content-Type: application/json
{
"workflow_type": "agents.metrics-step-close",
"initial_data": {
"step_metric_uuid": "value",
"session_uuid": "value",
"organization_uuid": "value",
"step_number": 123
}
}