Graph Service API

Reference for the SessionService methods, store traits, and remote-control messages that create, drive, and read execution graphs.

This page lists the public surface a caller uses to drive graphs: the SessionService methods of ag-session, the ag-store traits under them, and the remote-control messages. Graph Chat API and Graph Node API cover the model-facing interfaces.

SessionService🔗

A host serves the graph reads and actions only when SessionBackend::supports reports the matching SessionOperation: Graphs for session_graphs, GraphActions for act_on_session_graph, GraphNodeActions for its withdraw, pool, and orchestrator actions (a host that serves it serves GraphActions too), GenerateGraphProposal for generate_graph_proposal, SessionDocument for get_session_document, and MessageImages for send_message_with_images; others return SessionError::Operation.

MethodParametersReturnsErrorsDescription
generate_graph_proposal (async)&self; request: GenerateGraphProposalRequest with id: String, request: TurnPrompt and session_id: SessionId()SessionError: Returns admission, permissions, or persistence errors.Generates a proposal through the host's bounded worker workflow.
get_graph_proposal (async)&self; id: &strOption<GraphProposalState>SessionError: Returns query delivery or persistence errors.Queries pending, restored, or approved state without execution.
answer_graph_proposal (async)&self; id: &str; version: u32; answers: Vec<String>()SessionError: Returns stale-version, incomplete-answer, or generation-limit errors.Answers the complete question set on an exact proposal version.
regenerate_graph_proposal (async)&self; id: &str; version: u32()SessionError: Returns stale-version, approved-proposal, or exhausted-limit errors.Regenerates within the original captured generation ceiling.
revise_graph_proposal (async)&self; id: &str; version: u32; feedback: TurnPrompt()SessionError: Returns stale-version, empty-feedback, approved-proposal, or exhausted-limit errors.Regenerates with user feedback, including its images, added to the generation history, within the original captured generation ceiling.
approve_graph_proposal (async)&self; id: &str; version: u32()SessionError: Returns stale-version, resolution, permissions, or publication errors.Approves the exact preview before dispatch. Redelivery never dispatches.
cancel_graph_proposal (async)&self; id: &str; version: u32()SessionError: Returns stale-version or already-approved errors.Cancels a pending proposal and any active generating utility.
get_execution_graph (async)&self; graph_id: &strOption<ExecutionGraphProgress>SessionError: Returns failed persistence or query delivery errors.Reads graph/node progress and immutable execution history.
session_graphs (async)&self; request: SessionGraphsRequest with graph_id: Option<String>, node_id: Option<String> and session_id: SessionIdSessionGraphsSessionError: Rejects a graph_id of another session, and returns failed persistence or query delivery errors.Reads a session's graphs as an inspector shows them: every graph, the latest proposal with its preview, and the selected graph with its live progress and the selected node's outputs. Each node of the graph carries its pull request and whether it was withdrawn, beside its parent, and the answer lists the session's open pull requests and the resources its inspector header shows: worktrees, orchestrator calls, and whether publishing is allowed.
act_on_session_graph (async)&self; request: SessionGraphActionRequest with action: SessionGraphAction, graph_id: String, session_id: SessionId and snapshot: String()SessionError: Rejects a graph of another session, a graph that changed since request.snapshot was read, an action that snapshot does not offer, an empty reply, a budget or pool increase outside 1..= ExtendGraphBudgetRequest::MAX_ADDITIONAL_CALLS, and returns failed admission or delivery errors.Accepts an output, cancels, resumes, or retries a graph, replies to one of its nodes, adds provider calls to its spent budget, withdraws a node that never started, adds provider calls to its session's pool, or switches the session's orchestrator, as the graph's inspector does.
cancel_execution_graph (async)&self; request: GraphControlRequest with graph_id: String and revision: NonZeroU64()SessionError: Rejects missing/stale graphs and failed durable cancellation.Permanently cancels this graph without canceling unrelated session work.
resume_execution_graph (async)&self; request: ResumeExecutionGraphRequest with graph: GraphControlRequest()SessionError: Rejects canceled/stale graphs, graphs without recorded launch limits, or ineligible sessions.Resumes dispatch explicitly; failed nodes still require a new action.
extend_execution_graph_budget (async)&self; request: ExtendGraphBudgetRequest with action_id: String, additional_calls: usize, budget_id: String and graph: GraphControlRequest()SessionError: Rejects stale, completed, or canceled graphs, unknown budgets, amounts outside 1..=ExtendGraphBudgetRequest::MAX_ADDITIONAL_CALLS, conflicting action identities, and failed persistence.Adds provider calls to one launched budget through a recorded, idempotent extension; the launch limits stay unchanged.
withdraw_execution_graph_node (async)&self; request: WithdrawGraphNodeRequest with action_id: String, actor: String, graph: GraphControlRequest and node_id: String()SessionError: Rejects stale, canceled, completed, or focused-review graphs, unknown or already withdrawn nodes, a node, child, or dependent that started (the reason names it and the nodes that link it), an action identity reused for another withdrawal, and failed persistence.Withdraws a node that never started, together with its children when it is a parent and every unstarted node that depends on any of them, without changing the graph's revision. A child leaves its parent unless the parent depends on it, in which case the parent and its other children go too. The graph completes once its other nodes settle. Redelivering the same action withdraws nothing more. Callers own any confirmation; this method asks for none.
cancel_execution_graph_node (async)&self; request: CancelGraphNodeRequest with execution: GraphExecutionRef, graph: GraphControlRequest and node_id: String()SessionError: Rejects stale or canceled graphs, focused-review graphs, an execution that is not the node's latest or no longer runs, nodes that run outside a task conversation, and failed persistence.Cancels the exact running or queued execution of one node, releasing its resources once its worker cleans up, while the rest of the graph keeps running. Its dependents then wait on a failed prerequisite; a parent's children are ordinary nodes and keep running. Repeating it while the execution still runs changes nothing. Callers own any confirmation; this method asks for none.
continue_execution_graph_node (async)&self; request: ContinueGraphNodeRequest with action_id: String, execution: GraphExecutionRef, graph_id: String, kind: GraphNodeContinuation, node_id: String and revision: NonZeroU64()SessionError: Rejects stale sources, partial answers, conflicting action identities, canceled graphs, and failed persistence or delivery.Retries a failed node or answers its exact settled clarification set.
start_execution_graph (async)&self; request: StartExecutionGraphRequest with graph: ExecutionGraph and provider_call_limits: std::collections::BTreeMap<String, usize>()SessionError: Rejects unsupported profiles, stale/conflicting identities, missing budgets, ineligible sessions, and failed persistence or delivery.Starts an explicit static graph without waiting for model execution.
accept_execution_graph_result (async)&self; reference: GraphResultRef()SessionError: Rejects stale or unvalidated references and failed persistence.Accepts one exact validated output and releases its acceptance gate.
get_session (async)&self; session_id: &SessionIdOption<Session>SessionError: Returns an error when persisted data cannot be loaded or decoded.Loads one complete session aggregate by identifier.
get_session_document (async)&self; session_id: &SessionIdSessionDocumentSessionError: Returns an error when the host does not serve the document or cannot load it, and SessionError::NotFound when the caller's scope does not reach the session, such as a paired device asking about a session the host does not list.Reads one session's shared notes document: its current body and version, and every accepted write with its author, in version order. A session that never wrote one, or that the host does not know, reads as the empty document at version zero.
send_message (async)&self; session_id: &SessionId; message: impl Into<String> + Send()SessionError: Returns an error when the session cannot accept or enqueue the message.Sends a text message to one session.
send_message_with_images (async)&self; session_id: &SessionId; message: impl Into<String> + Send; images: Vec<MessageImage>()SessionError: Returns an error when the host does not take images in messages, or the session cannot accept or enqueue the message.Sends a message with images to one session. The host attaches the images as [Image #n], numbered in images order from 1.
answer_questions (async)&self; session_id: &SessionId; request: AnswerQuestionsRequest with answers: Vec<QuestionAnswer>, attachments: Vec<TurnPromptAttachment> and graph_question_target: Option<String>()SessionError: Returns an error when the answers are stale, incomplete, or cannot be enqueued as a follow-up turn.Answers the complete current clarification-question set.

send_message and send_message_with_images are how an API caller replies to waiting graph work: a message answers a waiting item first, in the order of reply order. get_session returns the session's graph summary and graph_question_target, which answer_questions echoes to answer a node's questions.

GraphNodeContinuation is Retry, RetryCommit, Answer {answers}, Reply {attachments, message}, or OrchestratorReply {message}; the host's own routes send Reply, and Answer is the structured form a service caller may send. RetryCommit runs only the commit steps of an Uncommitted node on its saved turn, and the store refuses it for any other node; Retry {node_id} sends it for such a node. SessionGraphAction is Accept {node_id, output_id}, Cancel, ExtendBudget {additional_calls, budget_id}, Reply {message, node_id}, Resume, or Retry {node_id}.

Store Traits🔗

Each trait's doc comments are its reference; the methods return Result<_, DbError>.

TraitForSource in crates/ag-store/src/
GraphRepositoryGraph snapshots, executions, results, controls, and budgetsexecution_graph/repository.rs
GraphProposalRepositoryProposal versions, approval, publication, and repliesexecution_graph/proposal.rs
SessionDocumentRepositoryThe session document and its entriessession_document.rs
SessionOrchestrationRepositoryThe orchestration row, directives, pool extensions, events, and automatic turnssession_orchestration.rs

Remote Control Messages🔗

Remote control serves these graph messages to paired devices; the schema is crates/ag-remote/schema/remote_protocol.json.

MethodRequiredOptionalDescription
act_on_session_graphaction, graph_id, session_id, snapshotadditional_calls, budget_id, enabled, message, node_id, output_idActs on a session's execution graph as the terminal's inspector does: accepts an output, retries or replies to a node, resumes or cancels the graph, or adds provider calls to its spent budget. Cancelling is permanent. Agentty refuses an action the graph's snapshot no longer matches or does not offer. Offered through the graph_actions capability.
answer_questionsanswers, session_idgraph_question_targetAnswers the session's complete current question set: its turn's questions, or, with graph_question_target, its graph_questions, which go to the graph work that asked them.
generate_graph_proposalmessage, session_idStarts model work that proposes an execution graph for the task in message, as the terminal's /graph does. The proposal appears in the session's graph; nothing launches until a chat reply approves it. Agentty refuses it unless the session is prepared and idle, so also for a draft that has not started, and refuses an empty or oversized task. Offered through the graph_proposal capability.
get_session_documentsession_idReads a session's shared notes document: the one text that its graph nodes, its main chat, and its user add notes to. A session that never wrote one reads as an empty document at version zero. Offered through the session_document capability.
get_session_graphssession_idgraph_id, known, node_idReads a session's graph proposal and execution graphs as the terminal's inspector shows them, without acting on any. Offered through the graphs capability.
send_messagemessage, session_idimagesSends one chat message, starting, resuming, or queueing a turn.

additional_calls of an extend_budget action is 1 to 1000, and images of send_message is accepted only when the host offers the images capability.

The action of act_on_session_graph is one of:

ValueDescription
acceptAccept a validated output, releasing the nodes that wait for it.
cancelCancel the graph for good.
extend_budgetAdd provider calls to the graph's spent budget.
extend_poolAdd provider calls to the session's pool, which its orchestrator allots from. Offered with the graph_node_actions capability.
replySend guidance that revises a settled node's output.
resumeRestart a paused graph.
retryRun a failed or cancelled node again.
set_orchestratorSwitch the session's orchestrator on or off. Offered with the graph_node_actions capability.
withdrawWithdraw a node that never started, with the nodes that could then no longer run. Offered with the graph_node_actions capability.

The graphs response carries graph, graphs, proposal, version, and unchanged. A session snapshot carries graph, the graph summary; graph_questions; and graph_question_target, which answer_questions echoes. A device's message answers a waiting graph item first, as the session API does.