Overview
The HITL (Human-in-the-Loop) review API provides endpoints for reviewing, refining, and approving AI-generated research plans before execution begins. These endpoints interact with the review state stored in Redis and coordinate with the Temporal workflow via gRPC signals. For a tutorial on using the HITL review system, see Human-in-the-Loop Review.Authentication
Required: Yes Include API key in header:Get Review State
Description
Returns the current review conversation state for a workflow. Use this to retrieve the initial research plan and track the review cycle.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workflow_id | string | Yes | Workflow ID (from task submission response) |
Headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | API authentication key |
Response
200 OK
| Header | Description |
|---|---|
ETag | Current version number (use with If-Match for concurrency control) |
| Field | Type | Description |
|---|---|---|
status | string | "reviewing" (waiting for input) or "approved" (plan accepted) |
round | integer | Current conversation round (starts at 1) |
version | integer | Monotonic version for optimistic concurrency |
current_plan | string | Latest actionable plan (set when LLM intent is "ready"). May be empty if LLM is still asking clarifying questions. |
rounds | array | Full conversation history |
rounds[].role | string | "assistant" (LLM) or "user" (human feedback) |
rounds[].message | string | Message content |
rounds[].timestamp | string | RFC 3339 timestamp |
query | string | Original task query |
401 Unauthorized
403 Forbidden
404 Not Found
Example
Submit Feedback
Description
Sends feedback to refine the research plan. The gateway forwards the feedback to the LLM service, which generates an updated plan incorporating the user’s input. The conversation round and version are incremented. A distributed Redis lock prevents concurrent feedback requests from racing during the LLM call.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workflow_id | string | Yes | Workflow ID |
Headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | API authentication key |
Content-Type | Yes | application/json |
If-Match | No | Version number for optimistic concurrency. If provided, the request is rejected with 409 if the current version does not match. |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be "feedback" |
message | string | Yes | Feedback text (max 10 KB) |
Request Body
Response
200 OK
| Header | Description |
|---|---|
ETag | Updated version number |
| Field | Type | Description |
|---|---|---|
status | string | Always "reviewing" for feedback responses |
plan.message | string | Updated plan from the LLM |
plan.round | integer | Current round number |
plan.version | integer | Updated version (for next If-Match) |
plan.intent | string | "feedback" (LLM asking questions) or "ready" (actionable plan proposed) |
400 Bad Request
404 Not Found
409 Conflict
Version mismatch:502 Bad Gateway
LLM service unavailable:Example
Approve Plan
Description
Approves the current research plan, unblocking the workflow to proceed with execution. The gateway sends a Temporal Signal to the waiting workflow, injecting the confirmed plan and review conversation into the task context.Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workflow_id | string | Yes | Workflow ID |
Headers
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes | API authentication key |
Content-Type | Yes | application/json |
If-Match | No | Version number for optimistic concurrency |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be "approve" |
Request Body
Response
200 OK
400 Bad Request
No plan available to approve:409 Conflict
Version mismatch:502 Bad Gateway
Example
Behavior Notes
- Redis TTL: Review state is stored in Redis with a TTL equal to the review timeout plus a 5-minute buffer (default: 20 minutes). After expiry, the review session is no longer accessible.
- Maximum rounds: 10 feedback rounds are permitted. At the final round, the LLM is instructed to produce a definitive plan. Beyond this limit, only approval is accepted.
- Ownership: Only the user who submitted the task can access its review state (enforced via
owner_user_idstored in Redis). - Concurrency: Both feedback and approval acquire a distributed Redis lock. If a feedback request is in progress (holding the lock), approval will fail fast with 409.
- SSE events: The review cycle emits
RESEARCH_PLAN_READY,REVIEW_USER_FEEDBACK,RESEARCH_PLAN_UPDATED, andRESEARCH_PLAN_APPROVEDevents to the Redis event stream. These appear in the SSE stream and are persisted for session history. - Token tracking: LLM token usage during review (feedback rounds) is recorded via
RecordTokenUsagegRPC for accurate cost accounting.