Skip to main content

Crate ag_session

Crate ag_session 

Source
Expand description

Frontend-neutral session management, selection catalog, and session models.

Host applications implement SessionBackend to connect the stable programmatic API to their persistence, agent, Git, and forge workflows. Callers such as background callers use SessionService without depending on terminal UI state.

Structs§

AcceptTaskChainPlanRequest
Explicit acceptance of one exact Planner version.
AcceptTaskPlanRequest
Producing task and attempt selected by the user for plan acceptance.
AcceptedTaskPlan
Caller-supplied, explicitly accepted plan for an implementation attempt.
AgentAnswerContent
Role-attributed task-chain answer stored as SessionMessageKind::AgentAnswer content.
AgentCliInfo
One locally runnable agent CLI and the installed version refreshed at startup.
AgentDefinition
One enabled agent loaded from a workspace agent definition.
AgentDefinitionSummary
Lightweight agent metadata returned by the definition catalog.
AgentSelection
Session-level agent selection that keeps provider kind and model together.
AnswerQuestionsRequest
Structured input for resuming one session from clarification questions.
ChatGptSignInOutcome
Account that a completed ChatGPT plan sign-in stored.
ContinueGraphNodeRequest
An explicit action against the exact latest execution of a node.
ContinueTaskChainRequest
Explicit revision, clarification, or retry of the current workflow stage.
CreateSessionRequest
Explicit input for creating one session.
CreateTaskRequest
A desired outcome to persist without admitting an attempt or starting work.
DurableMessageRequest
Idempotent turn submitted to one session.
ExecutionGraph
A revision of an arbitrary static execution graph owned by one session.
ExecutionGraphProgress
Read-only projection; operation/run records remain execution authorities.
GraphControlRequest
Revision-bound graph control; cancellation is terminal for this graph ID.
GraphDependency
One prerequisite; multiple gates on one producer are permitted.
GraphExecutionProfile
Requirements interpreted by a host before worker submission.
GraphInputBinding
A planned handoff; no attempt or result needs to exist when planning.
GraphNode
An agent invocation template, independent of built-in workflow roles.
GraphNodeProgress
One node’s latest state plus immutable attempt/run history.
GraphOutput
Named output containing one complete response under an existing schema.
GraphQuestionAnswer
One answer to the exact question produced by the source execution.
GraphResolvedInput
Exact input captured with a newly admitted execution.
GraphResult
Snapshot supplied by the host’s authoritative result store.
GraphResultRef
Immutable address of one persisted output version, excluding its body.
HarnessModelOption
One harness model a user can choose, with its cost, readiness, and context window.
PlanThenImplementAgents
Definitions assigned to workflow stages, independent of stage policy.
Project
Persisted project metadata used for multi-project management.
ProjectListItem
Aggregated project snapshot for list and switcher views.
QuestionAnswer
One structured response to a persisted clarification question.
QuestionItem
One extracted question with predefined answer choices.
ReplyToTaskChainRequest
Natural-language user reply addressed to a session’s latest workflow.
ResolvedEnv
Host-resolved local environment for execution in a shared session worktree.
ResumeExecutionGraphRequest
Explicit restart of dispatch, never an implicit retry of an admitted node.
ReviewRequest
Persisted forge linkage for one session.
ReviewRequestSummary
Normalized remote summary for one linked review request.
ServedModel
Model an OpenAI-compatible server serves, identified as openai-compatible/<served model>.
Session
Complete persisted session aggregate returned by the programmatic API.
SessionId
Shared stable identifier for one session.
SessionMessage
One persisted transcript message for a session.
SessionMessageKindParseError
Error returned when a stored session message kind is unknown.
SessionService
Stable programmatic facade for session lifecycle operations.
SessionSettings
Complete session-scoped execution settings returned by the API.
SessionStats
Token and diff usage statistics associated with one agent session or isolated prompt.
SessionTranscript
Ordered transcript view assembled from persisted session messages.
StartExecutionGraphRequest
Explicit static-graph launch, separate from ordinary chat and /plan.
StartPlanThenImplementRequest
Idempotent launch input captured before the first Planner execution.
StaticAgentAvailabilityProbe
Availability probe that returns one caller-provided snapshot.
SubmitAgentTaskRequest
Explicit role-aware attempt, separate from legacy session-context tasks.
SubmitTaskRequest
An explicit attempt to advance a task in an existing idle session.
Task
A desired outcome with retained attempt history, scoped to one session.
TaskAgentAssignment
Immutable role and provider/model selection assigned to one task.
TaskAgentContext
Durable identity of one task’s conversation and runtime resources.
TaskAgentHistory
Durable task conversation, independent of ordinary session messages.
TaskAgentInput
Explicit input for a task’s own conversation, excluding session replay.
TaskAgentTurn
One response retained in an isolated task conversation.
TaskAttempt
One turn and its ordered post-processing, backed by a unique operation.
TaskChain
Consistent workflow snapshot projected from one execution graph.

Enums§

AgentCliVersion
Automatic update and version probe state for one locally runnable agent CLI.
AgentContextRequirement
Inputs a workflow must explicitly supply, in addition to workspace access.
AgentDefinitionParseError
Error returned when one agent definition cannot be parsed safely.
AgentDefinitionSource
Location from which a catalog resolved a definition.
AgentKind
Supported agent provider families.
AgentModel
Supported agent model names across all providers.
AgentOutputKind
Semantic answer content; does not replace the protocol’s response schema.
CreateSessionMode
Creation strategy for a new session.
DurableMessageVisibility
Transcript treatment for one durable prompt.
EnvId
Stable identity and lifecycle owner of an execution environment.
ExecutionGraphStatus
Graph completion means every node settled without clarification.
FocusedReviewStatus
Durable state of one focused-review generation attempt.
ForgeKind
Shared forge family enum reused by persistence and forge adapters.
GraphBlockedReason
Stable reasons why a pending node cannot currently dispatch.
GraphCompletionGate
Completion condition, distinct from desired-outcome task completion.
GraphContext
Provider conversation lifetime and existing execution authority.
GraphContractError
A structural graph or exact-result binding violation.
GraphExecutionRef
Link to existing execution records; never a second execution status.
GraphNodeContinuation
Provider retries stay inside an attempt; these actions create a new one.
GraphNodeStatus
Node state never overwrites authoritative operation/run status.
GraphPostProcessing
Host mutation effects, independent of model tools and response schema.
GraphResultState
Host-attested output state, separate from attempt/run lifecycle.
GraphWorkspaceAccess
Resource requirement within one Env, not a security sandbox.
HarnessModelStatus
Whether a harness model can run a turn now.
ModelCost
Who pays for a harness model’s tokens and, for a hosted model, its price class as the ag-harness provider catalog declares it.
PermissionMode
Supported permission mode values for agent execution workflows.
ReasoningLevel
Supported reasoning-effort levels for task execution.
ResponseStyle
Preferred amount of detail in user-facing session responses.
ReviewRequestState
Normalized remote lifecycle state for one linked review request.
SessionDiffState
Known availability of a session worktree diff.
SessionError
Stable error returned by crate::SessionService operations.
SessionMessageKind
Durable category for one saved session transcript message.
SessionStatus
High-level lifecycle state for one session.
SettingName
Stable keys used in the setting and project_setting tables.
SpeedMode
Response-speed preference applied to one agent session.
TaskAgentRole
Built-in role contracts for a planner-to-implementer workflow.
TaskAttemptStatus
Operation lifecycle exposed by the task read model.
TaskChainPhase
Workflow presentation derived from the current node’s latest execution. Success records execution, never implicit acceptance of a plan or outcome.
TaskChainReplyOutcome
Workflow action admitted for one natural-language reply.
TranscriptNotice
Canonical labels for bracketed workflow notices appended to a session transcript.

Constants§

AGENT_PROFILE_PROMPT_MAX_BYTES
Maximum UTF-8 byte length retained for one agent prompt.
MINIMUM_RUNNING_CONTEXT_WINDOW
Smallest context window, in tokens, a local server may run a model with for harness turns. The system prompt, tool definitions, output schema, and response reservation leave too little room for a conversation below it, and Ollama fills a smaller window by silently dropping the start of the conversation.
TASK_CHAIN_PLAN_OUTPUT
Named Planner output that the Implementer consumes after acceptance.

Traits§

AgentAvailabilityProbe
Detects which provider CLIs and harness models are runnable on the current machine.
AgentSelectionMetadata
Human-readable metadata for slash-menu selectable items.
SessionBackend
Host implementation boundary for session persistence and workflows.

Functions§

activity_day_key_with_offset
Converts Unix timestamp seconds to a day key after applying a UTC offset.
agent_definition_identity
Reads an identity even for a disabled definition, which masks a bundled ID.
build_apply_review_prompt
Builds the agent-facing /apply prompt from focused-review suggestions.
bundled_agent_definitions
Bundled agents are available even when a repository has no .agents directory.
default_harness_model
Returns the model new harness sessions start on.
default_option_index
Returns the initial highlighted option for a clarification question.
has_actionable_review_suggestions
Returns whether focused-review markdown contains suggestions that /apply can act on.
mru_project_order
Returns indices into project_items ordered most-recently-opened first.
normalized_message_content
Returns raw persisted message content with only outer whitespace removed.
ordered_project_items
Returns the project rows named by project_order, skipping stale indices.
parse_agent_definition
Parses one .agents agent definition.
parse_agent_summary
Parses lightweight picker metadata from one .agents agent definition.
parse_persisted_session_agent_model
Parses one persisted session agent/model pair without deriving the agent from the model when the saved agent kind is available.
project_name_from_path
Derives a readable project name from its filesystem path.
resolve_agent_kind_for_model
Resolves a provider kind that can run model from the available provider list.
resolve_agent_selection_for_model
Resolves an AgentSelection for a model-only setting.
resolve_model_for_available_agent_kinds
Resolves one model against the currently available agent kinds.
resolve_prompt_model_agent_kind
Resolves the agent kind used for prompt-side /model selection.
review_suggestions
Extracts actionable suggestion content from focused-review markdown.
selectable_models_for_agent_kinds
Returns all selectable models owned by the provided agent kinds in stable settings and slash-menu order.
session_branch
Returns the default worktree branch name for a session.
stored_message_content
Returns the durable message content for one kind.

Type Aliases§

ChatGptSignInUrlHandler
Receives the browser URL of a ChatGPT sign-in once it is ready for the user, so the host can open it and show it as a fallback.