Scott Ai agent-loop API
The agent-loop API from Scott Ai — 16 operation(s) for agent-loop.
The agent-loop API from Scott Ai — 16 operation(s) for agent-loop.
openapi: 3.1.0
info:
title: One-Shot access agent-loop API
version: 1.0.0
tags:
- name: agent-loop
paths:
/agent-loop/workspaces:
get:
tags:
- agent-loop
summary: List Workspaces
description: List all workspaces the current user is a member of, ordered by most recent turn activity.
operationId: list_workspaces
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/ListWorkspacesResponse'
security:
- HTTPBearer: []
post:
tags:
- agent-loop
summary: Create Workspace
description: "Create a new workspace OR (for Scott pushes) upsert one keyed on\n`(captured_by_user_id, source_kind, source_id)`.\n\nTwo flows:\n - No `scott_push`: classic workspace creation. Single transaction.\n - With `scott_push`: idempotent. Same (user, source_kind, source_id)\n returns the same planspace. Push artifact metadata is replaced in\n place; scott_push turns are APPENDED past the existing chain tip\n (never deleted). Non-scott_push turns the user added in the Scott\n UI are never touched — they stay parented where the user put them\n and become branches at the prior tip after the next push."
operationId: create_workspace
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateWorkspaceRequest'
required: true
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateWorkspaceResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
security:
- HTTPBearer: []
/agent-loop/workspaces/{workspace_id}:
delete:
tags:
- agent-loop
summary: Delete Workspace
description: Delete workspace and all its turns (cascade).
operationId: delete_workspace
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Delete Workspace
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
patch:
tags:
- agent-loop
summary: Update Workspace
description: Update workspace settings.
operationId: update_workspace
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateWorkspaceRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Update Workspace
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/turns:
post:
tags:
- agent-loop
summary: Create Turn
description: 'Write-ahead: create a pending turn before agent starts running.'
operationId: create_turn
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTurnRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTurnResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/turns/{turn_id}:
patch:
tags:
- agent-loop
summary: Update Turn
description: 'Single completion call — updates turn with all results at once.
Dual-auth (see ``require_turn_access``): a per-turn agent-svc JWT bound to
this ``turn_id`` is the agent-service path; Stytch session is the user
path. Both routes resolve to ``actor.user_id`` for cursor advances and
downstream attribution.'
operationId: update_turn
parameters:
- name: turn_id
in: path
required: true
schema:
type: string
title: Turn Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateTurnRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Update Turn
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/state:
get:
tags:
- agent-loop
summary: Get Workspace State
description: 'Single call: all turns with DAG annotations + cursor position.
Anonymous access allowed for public workspaces (cursor/member tracking skipped).
Pure read — no E2B calls. Frontend calls /wake separately to ensure the sandbox is running.'
operationId: get_workspace_state
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/WorkspaceStateResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/events:
get:
tags:
- agent-loop
summary: Workspace Event Stream
description: 'SSE stream of state-change events for workspace members.
Strict-membership only: the agent-service shared-secret principal is
rejected so the bypass in ``assert_workspace_access`` can''t be reused
to subscribe to arbitrary workspaces.'
operationId: workspace_event_stream
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
- name: token
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Token
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/wake:
post:
tags:
- agent-loop
summary: Wake Workspace
description: 'Ensure the sandbox is running. Returns its current URL.
For Electron workspaces returns ''electron'' immediately (no E2B calls).
For E2B workspaces: health-checks the shared sandbox and recreates it if unhealthy.'
operationId: wake_workspace
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/WakeWorkspaceResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/context:
get:
tags:
- agent-loop
summary: Get Workspace Context
description: Walk parent_id chain and optionally bind the response to one document node.
operationId: get_workspace_context
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
- name: from_turn_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: From Turn Id
- name: snapshot_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Snapshot Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/WorkspaceSnapshotResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/review-chat/turns:
post:
tags:
- agent-loop
summary: Create Review Chat Turn
description: 'Open or extend the caller''s private review-chat thread on a snapshot.
Renderer-facing (workspace membership gates the call; the thread is the
caller''s own). Writes a pending review_chat_turns row, then mints a handoff
JWT carrying caps=[''review-chat-turn''] plus the snapshot_id claim that flips
agent-service into the read-only review sandbox. The claim — never a body
flag — is the source of truth for the turn kind. Returns the handoff code
the renderer forwards to agent-service.'
operationId: create_review_chat_turn
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReviewChatTurnRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReviewChatTurnResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
get:
tags:
- agent-loop
summary: List Review Chat Turns
description: 'List the caller''s private review-chat thread on a snapshot (renderer-facing).
Workspace membership gates the call; the thread is scoped to the
authenticated reviewer, so one reviewer never sees another''s thread and the
contributor sees none. Turns come back oldest-first so the Chat tab repaints
the conversation on reload and chains the next message onto the last. The
agent-facing context GET is the wrong surface here: it needs the review-chat
JWT the renderer never holds and rebuilds one focal turn''s ancestry, not the
whole thread.'
operationId: list_review_chat_turns
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
- name: snapshot_id
in: query
required: true
schema:
type: string
title: Snapshot Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/ReviewChatThreadResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/review-chat/context:
get:
tags:
- agent-loop
summary: Get Review Chat Context
description: 'Snapshot-scoped context for an agent-service review-chat turn.
Agent-service-facing (caps=[''review-chat-turn'']). The JWT''s snapshot_id and
user_id (the reviewer) scope the entire response; request inputs cannot
widen it. Returns the one snapshot''s content, workspace identity + connected
sources, comments on that snapshot only, and this private thread''s ancestry.
Deliberately never touches the workspace /context walk.'
operationId: get_review_chat_context
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
- name: from_turn_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: From Turn Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/ReviewChatContextResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/review-chat/turns/{turn_id}:
patch:
tags:
- agent-loop
summary: Update Review Chat Turn
description: 'Persist agent output onto a review-chat turn (agent-service-facing).
The JWT is bound to this ``turn_id`` (caps=[''review-chat-turn'']); the
service cross-checks workspace + reviewer ownership before writing. Same
body shape as the contributor PATCH /turns/{id}. No cursor advance — review
chat is off the DAG.'
operationId: update_review_chat_turn
parameters:
- name: turn_id
in: path
required: true
schema:
type: string
title: Turn Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateTurnRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Update Review Chat Turn
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/access-token:
post:
tags:
- agent-loop
summary: Mint Access Token
description: Issue a short-lived JWT for direct frontend → agent-service communication.
operationId: mint_access_token
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/AccessTokenResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/internal/workspaces/{workspace_id}/connected-sources/{connected_source_id}/retrieval-details:
get:
tags:
- agent-loop
summary: Get Connected Source Retrieval Details
description: Per-turn agent-svc JWT (``turn-write`` OR ``review-chat-turn`` cap, ``workspace_id`` claim matches path).
operationId: get_connected_source_retrieval_details
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
- name: connected_source_id
in: path
required: true
schema:
type: string
title: Connected Source Id
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RetrievalResult'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/internal/agent-token/redeem:
post:
tags:
- agent-loop
summary: Redeem Handoff Code
operationId: redeem_handoff_code
parameters:
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RedeemHandoffRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/RedeemHandoffResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/internal/sandbox/heartbeat:
post:
tags:
- agent-loop
summary: Sandbox Heartbeat
operationId: sandbox_heartbeat
parameters:
- name: authorization
in: header
required: false
schema:
anyOf:
- type: string
- type: 'null'
title: Authorization
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
additionalProperties: true
title: Response Sandbox Heartbeat
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/agent-loop/workspaces/{workspace_id}/cursor:
put:
tags:
- agent-loop
summary: Upsert Cursor
description: Upsert workspace cursor — tracks where this user is in the Turn DAG.
operationId: upsert_cursor
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpsertCursorRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CursorResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
get:
tags:
- agent-loop
summary: Get Cursor
description: Get current cursor position for this user in the workspace.
operationId: get_cursor
security:
- HTTPBearer: []
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
title: Workspace Id
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CursorResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
components:
schemas:
WorkspaceConfig:
properties:
id:
type: string
title: Id
name:
type: string
title: Name
created_at:
type: string
format: date-time
title: Created At
description:
anyOf:
- type: string
- type: 'null'
title: Description
model:
anyOf:
- type: string
- type: 'null'
title: Model
system_prompt:
anyOf:
- type: string
- type: 'null'
title: System Prompt
connected_sources:
anyOf:
- items:
$ref: '#/components/schemas/ConnectedSource'
type: array
- type: 'null'
title: Connected Sources
connected_sources_fingerprint:
anyOf:
- type: string
- type: 'null'
title: Connected Sources Fingerprint
type: object
required:
- id
- name
- created_at
title: WorkspaceConfig
description: Agent-service hydration. Used in WorkspaceSnapshotResponse only.
ChangeEntry:
properties:
changeType:
type: string
enum:
- added
- modified
- removed
title: Changetype
concept:
type: string
title: Concept
summary:
type: string
title: Summary
sectionHeading:
anyOf:
- type: string
- type: 'null'
title: Sectionheading
type: object
required:
- changeType
- concept
- summary
title: ChangeEntry
description: 'One semantic change emitted by the agent''s `write_document` tool.
Field-name casing matches the agent''s serialization (camelCase) so
Pydantic round-trips without aliasing.'
UploadedFileSourceConfig:
properties:
file_id:
type: string
title: File Id
type: object
required:
- file_id
title: UploadedFileSourceConfig
description: Configuration for an uploaded file source
PromptContextTurn:
properties:
text:
type: string
title: Text
ts:
anyOf:
- type: string
- type: 'null'
title: Ts
apiCalls:
type: integer
title: Apicalls
here:
type: boolean
title: Here
additionalProperties: false
type: object
required:
- text
- apiCalls
- here
title: PromptContextTurn
RetrievalKind:
type: string
enum:
- git
- file
title: RetrievalKind
description: Kind of retrieval method (git clone, file download, etc.)
CreateWorkspaceResponse:
properties:
workspace_id:
type: string
title: Workspace Id
initial_turn_id:
anyOf:
- type: string
- type: 'null'
title: Initial Turn Id
final_turn_id:
anyOf:
- type: string
- type: 'null'
title: Final Turn Id
planspace_url:
type: string
title: Planspace Url
type: object
required:
- workspace_id
- planspace_url
title: CreateWorkspaceResponse
ArtifactContent:
properties:
blocks:
items: {}
type: array
title: Blocks
markdown:
type: string
title: Markdown
type: object
required:
- blocks
- markdown
title: ArtifactContent
description: 'Blocks + markdown to render. Selection rule lives in
`_build_artifact_summaries` (cursor-scoped latest capture, else
creation node).'
ReviewChatContextResponse:
properties:
snapshot:
$ref: '#/components/schemas/SnapshotInfo'
workspace:
$ref: '#/components/schemas/WorkspaceContextInfo'
comments:
items:
$ref: '#/components/schemas/CommentSnapshot'
type: array
title: Comments
default: []
turns:
items:
$ref: '#/components/schemas/ReviewerContextTurn'
type: array
title: Turns
type: object
required:
- snapshot
- workspace
- turns
title: ReviewChatContextResponse
description: 'Review-chat''s snapshot-scoped context. Shape lives in
SnapshotScopedContext; this subclass owns review-chat''s name + OpenAPI id.'
TokenUsage:
properties:
inputUncached:
type: integer
title: Inputuncached
inputCacheCreate:
type: integer
title: Inputcachecreate
inputCacheRead:
type: integer
title: Inputcacheread
output:
type: integer
title: Output
total:
type: integer
title: Total
additionalProperties: false
type: object
required:
- inputUncached
- inputCacheCreate
- inputCacheRead
- output
- total
title: TokenUsage
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
input:
title: Input
ctx:
type: object
title: Context
type: object
required:
- loc
- msg
- type
title: ValidationError
UpdateTurnRequest:
properties:
status:
anyOf:
- type: string
- type: 'null'
title: Status
assistant_text:
anyOf:
- type: string
- type: 'null'
title: Assistant Text
tool_calls:
anyOf:
- {}
- type: 'null'
title: Tool Calls
message_deltas:
anyOf:
- {}
- type: 'null'
title: Message Deltas
usage:
anyOf:
- {}
- type: 'null'
title: Usage
error:
anyOf:
- type: string
- type: 'null'
title: Error
type: object
title: UpdateTurnRequest
ReviewChatThreadTurn:
properties:
id:
type: string
title: Id
parent_id:
anyOf:
- type: string
- type: 'null'
title: Parent Id
status:
type: string
title: Status
user_message:
anyOf:
- type: string
- type: 'null'
title: User Message
assistant_text:
anyOf:
- type: string
- type: 'null'
title: Assistant Text
created_at:
type: string
format: date-time
title: Created At
type: object
required:
- id
- parent_id
- status
- user_message
- assistant_text
- created_at
title: ReviewChatThreadTurn
description: 'One persisted review-chat turn for renderer rehydration. Mirrors the
contributor TurnSummary fields the Chat tab paints: the reviewer''s message
and the final assistant_text (history renders from the string, not blocks).'
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
type: array
title: Detail
type: object
title: HTTPValidationError
RedeemHandoffRequest:
properties:
handoff_code:
type: string
title: Handoff Code
type: object
required:
- handoff_code
title: RedeemHandoffRequest
WorkspaceListItem:
properties:
id:
type: string
title: Id
name:
type: string
title: Name
created_at:
type: string
format: date-time
title: Created At
use_local_sandbox:
type: boolean
title: Use Local Sandbox
default: false
pinned:
type: boolean
title: Pinned
default: false
is_example:
type: boolean
title: Is Example
default: false
doc_count:
type: integer
title: Doc Count
default: 0
latest_doc_label:
anyOf:
- type: string
- type: 'null'
title: Latest Doc Label
review_status:
type: string
title: Review Status
default: draft
owner_user_id:
anyOf:
- type: string
- type: 'null'
title: Owner User Id
owner_display_name:
anyOf:
- type: string
- type: 'null'
title: Owner Display Name
member_count:
type: integer
title: Member Count
default: 0
viewer_role:
anyOf:
- type: string
enum:
- owner
- editor
- viewer
- commenter
- type: 'null'
title: Viewer Role
type: object
required:
- id
- name
- created_at
title: WorkspaceListItem
description: GET /workspaces list entry. Adds turn aggregates.
CreateReviewChatTurnResponse:
properties:
turn_id:
type: string
title: Turn Id
handoff_code:
type: string
title: Handoff Code
description: Single-use code redeemable at /agent-loop/internal/agent-token/redeem for the review-chat agent-svc JWT (caps=['review-chat-turn'] + snapshot_id) bound to this turn. 60s TTL.
type: object
required:
- turn_id
- handoff_code
title: CreateReviewChatTurnResponse
UploadedFileSourceMetadata:
properties:
filename:
type: string
title: Filename
# --- truncated at 32 KB (70 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/scott-ai/refs/heads/main/openapi/scott-ai-agent-loop-api-openapi.yml