SyncSession
One conversation, on the blocking surface — the sync twin of Session.
Class in muse_code
The read views (fold, pending) are the async session’s own
objects: they are plain synchronous reads already, and a wrapped copy
would be a second surface to keep honest. The handler registrations
(on_approval …) delegate unchanged — the handlers run on the private
loop while a blocking verb is pumping it. The synchronous MUTATORS
(turn, stop_retrying, replay_answered) route through the
runner’s lock: they touch structures the loop’s own tasks touch, and an
unlocked turn() racing a pumping verb can double-mint a handle.
Constructor
Section titled “Constructor”SyncSession(session: Session[_I], runner: _LoopRunner)
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
session_id |
str |
The server-named session id. |
opening |
SessionOpening | None |
Which verb opened this session, and what it answered. |
durability |
SessionDurabilityProfile |
The profile this session discharges a host death under. |
fold |
SessionFoldView |
The fold’s read view (the async session’s own object). |
pending |
PendingCommandView[_I] |
The pending set’s read/safe-drive view; same threading caveat as fold — read from the verb-driving thread. |
Methods
Section titled “Methods”| Method | Signature | Description |
|---|---|---|
send_user_turn |
send_user_turn(options: SendUserTurnOptions[_I]) -> 'SyncTurn[_I]' |
Submit a user turn and block for its ack (twin of send_user_turn). |
run |
run(prompt: RunInput, *, display_text: str | None = None, if_busy: IfBusy | None = None, reasoning_effort: ReasoningEffort | None = None, workspace_roots: List[str] | None = None, user_shell: TurnUserShell | None = None) -> RunResult |
Run one turn to its end and block for its result (twin of run). There is no cancel hook here: to stop a turn, use send_user_turn and SyncTurn.cancel, or the async facade. |
turn |
turn(turn_id: str) -> 'SyncTurn[_I]' |
The handle for a turn, created on first mention from either side. |
on_approval |
on_approval(handler: ApprovalHandler) -> None |
Answer approvals with handler, unchanged. |
on_approval_error |
on_approval_error(handler: ApprovalFailureHandler) -> None |
Observe approval round trips that did not complete. |
on_gap_error |
on_gap_error(handler: GapFillFailureHandler) -> None |
Observe the protocol fills that did not complete. |
answer_user_input |
answer_user_input(user_input_id: str, answers: Sequence[UserInputAnswer]) -> UserInputAnswerResult |
Blocking twin of answer_user_input. |
list_tasks |
list_tasks() -> TaskListResult |
Blocking twin of list_tasks. |
list_skills |
list_skills() -> SkillListResult |
Blocking twin of list_skills. |
list_hooks |
list_hooks() -> HookListResult |
Blocking twin of list_hooks. |
pause_workflow |
pause_workflow(workflow_run_id: str) -> WorkflowControlResult |
Blocking twin of pause_workflow. |
resume_workflow |
resume_workflow(workflow_run_id: str) -> WorkflowResumeResult |
Blocking twin of resume_workflow. |
request_recap |
request_recap() -> RecapRequestResult |
Blocking twin of request_recap. |
submit_feedback |
submit_feedback(input: FeedbackSubmitParams) -> FeedbackSubmitResult |
Blocking twin of submit_feedback. |
open_side_chat |
open_side_chat() -> SessionSideChatResult |
Blocking twin of open_side_chat. |
fork |
fork(*, cut_point: ForkCutPoint | None = None, exclude_items: bool | None = None) -> SessionForkResult |
Blocking twin of fork. |
compact |
compact(*, turn_id: str | None = None) -> SessionCompactResult |
Blocking twin of compact. |
set_model |
set_model(model: ModelSelection) -> SessionSetModelResult |
Blocking twin of set_model. |
set_reasoning_effort |
set_reasoning_effort(reasoning_effort: ReasoningEffort) -> SessionSetReasoningEffortResult |
Blocking twin of set_reasoning_effort. |
set_approval_mode |
set_approval_mode(mode: ApprovalMode) -> SessionSetApprovalModeResult |
Blocking twin of set_approval_mode. |
rename |
rename(name: str) -> SessionRenameResult |
Blocking twin of rename. |
leave |
leave(*, stop: bool | None = None) -> SessionLeaveResult |
Blocking twin of leave. |
send_subagent_message |
send_subagent_message(subagent_id: str, body: str) -> CommandAcceptedResult |
Blocking twin of send_subagent_message. |
followup_subagent_task |
followup_subagent_task(subagent_id: str, body: str) -> CommandAcceptedResult |
Blocking twin of followup_subagent_task. |
interrupt_subagent |
interrupt_subagent(subagent_id: str, *, reason: str | None = None) -> CommandAcceptedResult |
Blocking twin of interrupt_subagent. |
stop_subagent |
stop_subagent(subagent_id: str, *, reason: str | None = None) -> CommandAcceptedResult |
Blocking twin of stop_subagent. |
resume_subagent |
resume_subagent(subagent_id: str) -> CommandAcceptedResult |
Blocking twin of resume_subagent. |
reopen_subagent |
reopen_subagent(subagent_id: str) -> CommandAcceptedResult |
Blocking twin of reopen_subagent. |
close_subagent |
close_subagent(subagent_id: str, *, reason: str | None = None) -> CommandAcceptedResult |
Blocking twin of close_subagent. |
read_subagent_result |
read_subagent_result(subagent_id: str) -> CommandAcceptedResult |
Blocking twin of read_subagent_result. |
list_plugins |
list_plugins() -> PluginListResult |
Blocking twin of list_plugins. |
install_plugin |
install_plugin(target: PluginInstallTarget) -> PluginInstallResult |
Blocking twin of install_plugin. |
set_skill_activation |
set_skill_activation(*, selector: str, scope: SkillActivationScope, activation: SkillActivationState) -> SkillSetActivationResult |
Blocking twin of set_skill_activation. |
stop_retrying |
stop_retrying(command_id: str) -> PendingRetirement[_I] | None |
The “Abandoned” verb: stop one entry’s retry loop (sync, locked). |
replay_answered |
replay_answered(command_id: str, answer: ReplayAnswer[_I]) -> PendingRetirement[_I] | Literal['held'] |
Feed a consumer-driven replay’s answer through the protocol rules. |
resolve_snapshot_join |
resolve_snapshot_join(facts: SnapshotJoinFacts) -> tuple[PendingRetirement[_I], ...] |
Blocking twin of resolve_snapshot_join. |
resolve_reconnect |
resolve_reconnect() -> tuple[PendingRetirement[_I], ...] |
Blocking twin of resolve_reconnect. |
Source
clients/sdk-py/src/muse_code/sync_facade.py:402