Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(session-host): add session host builder setters

Steven Enamakel375f6ea8954e
diff --git a/crates/openhuman-core/src/agent/session_host/builder/setters.rs b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
index 19ab57288e..4c683a0e8d 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/setters.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/setters.rs
@@ -265,19 +265,15 @@ impl SessionHostBuilder {
/// This value is stamped onto the built [`OpenHumanSessionHost`] and surfaces in
/// the following places:
///
- /// * **Transcript filename on disk** — `transcript::write_transcript`
- /// and `transcript::find_latest_transcript` use it as the
- /// `{agent}` prefix in `sessions/DDMMYYYY/{agent}_{index}.md`.
- /// Both the write path and the resume-lookup path read the same
- /// field on `self`, so a session is always self-consistent; the
- /// user-visible signal is which filename the transcript lands
- /// under. Leaving it at the legacy `"main"` fallback silently
- /// misfiles every non-orchestrator session under `main_*.md`.
- /// * **Transcript metadata header** — `transcript::write_transcript`
- /// stamps it into the `<!-- session_transcript\nagent: {name}\n… -->`
- /// block at the top of every `.md` file. This is the ground-truth
- /// signal for "which agent definition ran this session" when
- /// inspecting transcripts after the fact.
+ /// * **Transcript identity** — the session's store key and its
+ /// `SessionRef` use it, on both the write path and the resume-lookup
+ /// path, so a session is always self-consistent. Leaving it at the
+ /// legacy `"main"` fallback silently misfiles every non-orchestrator
+ /// session under `main`.
+ /// * **Transcript metadata header** — it is stamped into the transcript's
+ /// `_meta` (`agent`, `agent_id`). This is the ground-truth signal for
+ /// "which agent definition ran this session" when inspecting
+ /// transcripts after the fact.
/// * **[`PromptContext::agent_id`]** at prompt-build time (see
/// `turn.rs`). The stamped `prompt_builder` injected by
/// [`OpenHumanSessionHost::from_config_for_agent`] is what actually
diff --git a/crates/openhuman-core/src/agent/session_host/types.rs b/crates/openhuman-core/src/agent/session_host/types.rs
index d79fd77cca..97d04e265b 100644
--- a/crates/openhuman-core/src/agent/session_host/types.rs
+++ b/crates/openhuman-core/src/agent/session_host/types.rs
@@ -320,22 +320,22 @@ pub struct OpenHumanSessionHost {
///
/// [`AgentDefinitionRegistry`]: crate::agent::harness::host_definition::AgentDefinitionRegistry
pub(super) agent_definition_id: String,
- /// Injected transcript locator, or `None` to use real files.
+ /// Injected transcript locator, or `None` to resolve the session store for
+ /// this agent key.
///
/// The single injection point for the whole transcript seam: it resolves
/// both resume reads (`latest_for_agent`, `root_for_thread`) and binds this
/// session's write handle (`open_stem`). `None` is the production default
/// and is resolved *lazily* by
- /// [`OpenHumanSessionHost::session_locator`][Self::session_locator] into a
- /// [`FileTranscriptLocator`][tinyagents_session::transcript::FileTranscriptLocator]
- /// over the **current** `workspace_dir` — never
+ /// [`OpenHumanSessionHost::session_locator`][Self::session_locator] into the
+ /// session store's transcripts for the **current** `workspace_dir` — never
/// captured at build time, because callers (tests especially) reassign
/// `workspace_dir` after `build()` and a frozen locator would silently keep
/// reading the old directory.
pub(super) session_history_locator:
Option<std::sync::Arc<dyn tinyagents_session::transcript::TranscriptLocator>>,
/// First-call memo for [`OpenHumanSessionHost::session_locator`][Self::session_locator]'s
- /// lazily-constructed `FileTranscriptLocator` (the `session_history_locator` `None` branch).
+ /// lazily-resolved store locator (the `session_history_locator` `None` branch).
///
/// tinyagents' `SessionBuilder` only accepts a later transcript-target
/// change when it is the *same* locator object (`Arc::ptr_eq`), not merely
diff --git a/crates/openhuman-core/src/threads/README.md b/crates/openhuman-core/src/threads/README.md
index 35c65c961a..b2a43f5d86 100644
--- a/crates/openhuman-core/src/threads/README.md
+++ b/crates/openhuman-core/src/threads/README.md
@@ -34,9 +34,14 @@ agent reply, which `threads.messages_list` returns. The transcript is what
the model sees, written by the agent session host through the session store
port, and is the source for `threads.transcript_get` and `threads.token_usage`.
Every transcript read here goes through that port under the key the session
-host wrote with: `ops::support::transcript_store(ctx)` resolves it from the
-request's own context (`<profile>~<agent>` for a SaaS profile, else the
-context's agent, else the chat agent id), never from ambient state. The turn-state snapshots
+host wrote with. The web-chat checkout records that key with the thread the
+first time a session is bound to it (`threads::store::bind_transcript_key`,
+first writer wins, the `threads_transcript_keys` collection in the thread's
+scope), and `ops::support::transcript_store(ctx, thread_id)` reads it back, so
+a later `[agent] chat_agent_id` change cannot strand the thread's earlier
+turns. A thread with no record resolves the key as the session host would
+today, from the request's own context (`<profile>~<agent>` for a SaaS profile,
+else the context's agent, else the chat agent id), never from ambient state. The turn-state snapshots
record what a turn was doing (phase, tool timeline, streamed text) so a client
that reloads mid-turn, or after a restart, can rebuild the process view.