Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(agents): reduce latency before first streamed answer (#7574)

Wolf Mermelsteine5eba0a078c8
diff --git a/apps/web/src/features/block-agent/context/configure-session-model.test.ts b/apps/web/src/features/block-agent/context/configure-session-model.test.ts
index 296bcb0fa7..8e8451fe10 100644
--- a/apps/web/src/features/block-agent/context/configure-session-model.test.ts
+++ b/apps/web/src/features/block-agent/context/configure-session-model.test.ts
@@ -51,6 +51,17 @@ const flush = async () => {
};
describe('combined model and effort selection', () => {
+ it('can confirm effort without changing the runtime model', async () => {
+ const f = fixture();
+ const result = configureSessionModel(f.session, undefined, selection);
+ await flush();
+ expect(f.issue.mock.calls).toEqual([
+ [{ type: 'setConfigOption', ...selection }],
+ ]);
+ f.confirm(1);
+ await result;
+ });
+
it('waits for the model confirmation before issuing the opaque effort, then waits for effort confirmation', async () => {
const f = fixture();
let finished = false;
diff --git a/apps/web/src/features/block-agent/context/configure-session-model.ts b/apps/web/src/features/block-agent/context/configure-session-model.ts
index 5a80e2a892..62c6c31ac5 100644
--- a/apps/web/src/features/block-agent/context/configure-session-model.ts
+++ b/apps/web/src/features/block-agent/context/configure-session-model.ts
@@ -8,10 +8,10 @@ import { confirmSessionControl } from './confirm-session-control';
/** Validate against the model's confirmed runtime snapshot before setting effort. */
export async function configureSessionModel(
session: Pick<AgentSession, 'issue' | 'snapshot' | 'subscribe'>,
- model: string,
+ model: string | undefined,
effort?: EffortSelection
) {
- if ((await session.snapshot()).metadata.model !== model) {
+ if (model && (await session.snapshot()).metadata.model !== model) {
await confirmSessionControl(session, { type: 'setModel', model });
}
if (!effort) return;
diff --git a/apps/web/src/features/block-agent/context/pending-session.ts b/apps/web/src/features/block-agent/context/pending-session.ts
index 48c5fd43c1..954834e5e3 100644
--- a/apps/web/src/features/block-agent/context/pending-session.ts
+++ b/apps/web/src/features/block-agent/context/pending-session.ts
@@ -32,8 +32,7 @@ import type {
import { type Accessor, createSignal } from 'solid-js';
import { v7 as uuidv7 } from 'uuid';
import { issueSessionAction } from '../queries/issue-session-action';
-import { effortConfigOption } from '../state/session-config';
-import { confirmSessionControl } from './confirm-session-control';
+import { configureSessionModel } from './configure-session-model';
export type PendingSession = {
/** The session's id, once the create has made it real. */
@@ -157,32 +156,11 @@ export function startPendingSession(
if (options.modelOverride || options.effortOverride) {
await session.load();
trace?.stage('loaded');
- if (options.modelOverride) {
- await confirmSessionControl(session, {
- type: 'setModel',
- model: options.modelOverride,
- });
- }
- if (options.effortOverride) {
- const snapshot = await session.snapshot();
- const effort = effortConfigOption(
- snapshot.metadata.configOptions
- );
- if (
- effort?.id !== options.effortOverride.configId ||
- !effort.options.some(
- (option) => option.value === options.effortOverride?.value
- )
- ) {
- throw new Error(
- 'The selected effort is no longer available for this model.'
- );
- }
- await confirmSessionControl(session, {
- type: 'setConfigOption',
- ...options.effortOverride,
- });
- }
+ await configureSessionModel(
+ session,
+ options.modelOverride,
+ options.effortOverride
+ );
trace?.stage('configured');
}
setSessionId(created);
diff --git a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
index 19b1f240f4..affe5076d4 100644
--- a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
+++ b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
@@ -22,6 +22,7 @@ const create = vi.hoisted(() => ({
confirm: undefined as ((error?: string) => void) | undefined,
release: vi.fn(),
attribution: vi.fn(),
+ confirmedModel: undefined as string | undefined,
}));
vi.mock('@service-agent-harness/client', () => ({
@@ -84,6 +85,7 @@ vi.mock('@core/agent-session/AgentSession', () => ({
]
: [],
metadata: {
+ model: create.confirmedModel,
configOptions: [
{
id: 'effort',
@@ -127,6 +129,7 @@ beforeEach(() => {
create.release.mockReset();
create.autoConfirm = true;
create.confirm = undefined;
+ create.confirmedModel = undefined;
});
describe('a block id that is already a session', () => {
@@ -142,6 +145,25 @@ describe('a block id that is already a session', () => {
});
describe('an id whose create is in flight', () => {
+ it('sends immediately when the runtime already confirms the requested model and effort', async () => {
+ create.confirmedModel = 'model-2';
+ create.control.mockResolvedValue({
+ isErr: () => false,
+ value: { actionId: 'prompt', status: 'sent' },
+ });
+ const placeholder = startPendingSession({
+ prompt: 'Hello',
+ modelOverride: 'model-2',
+ effortOverride: { configId: 'effort', value: 'low' },
+ });
+ create.resolve?.();
+ await flush();
+ expect(create.control.mock.calls).toEqual([
+ [placeholder, { type: 'prompt', prompt: 'Hello' }],
+ ]);
+ expect(create.release).toHaveBeenCalledTimes(1);
+ });
+
it('keeps initial context as a draft after startup without issuing a prompt', async () => {
const placeholder = startPendingSession({
initialInput: 'Document context ',
diff --git a/crates/agent_session/src/domain/service.rs b/crates/agent_session/src/domain/service.rs
index 650b538b07..36f05778fc 100644
--- a/crates/agent_session/src/domain/service.rs
+++ b/crates/agent_session/src/domain/service.rs
@@ -23,9 +23,12 @@
//! happens has to be published from there. The push cannot fail the durable
//! append - see [`AgentSessionRealtime`].
+mod first_output;
#[cfg(test)]
mod test;
+use first_output::FirstOutput;
+
use std::sync::Arc;
use agent_client_protocol::RawJsonRpcMessage;
@@ -1254,6 +1257,9 @@ fn owner_access_session_id(
/// append order, so a lost suffix never punches a hole in the middle - and
/// the latency a viewer sees on streamed output.
const LOG_FLUSH_INTERVAL: std::time::Duration = std::time::Duration::from_millis(1500);
+/// Coalesce the start of an answer just enough to include words after a
+/// Markdown prefix, instead of publishing only `**` or a heading marker.
+const FIRST_OUTPUT_FLUSH_INTERVAL: std::time::Duration = std::time::Duration::from_millis(50);
/// How many frames may accumulate before a flush happens regardless of age,
/// bounding memory, the size of one insert and one publish, and what a crash
/// could lose.
@@ -1267,7 +1273,9 @@ const MAX_PENDING_LOG_FRAMES: usize = 256;
/// buffered under a claim and, [`MAX_PENDING_LOG_FRAMES`] at a time or every
/// [`LOG_FLUSH_INTERVAL`], written as one fenced insert and pushed to viewers
/// as one publish, instead of costing a transaction, an audience lookup and
-/// a gateway round trip each. Only plain to-server notifications take that
+/// a gateway round trip each. The first visible output and initial prose of a
+/// live turn use [`FIRST_OUTPUT_FLUSH_INTERVAL`] to avoid delaying the answer's start.
+/// Only plain to-server notifications take that
/// path: anything the store projects (system events, a load boundary, a
/// Cursor checkpoint) or the runtime will act on writes the buffer out
/// first and then lands at once through the single-frame path, exactly as
@@ -1312,6 +1320,8 @@ pub struct LiveSessionLogWriter<R, Rt> {
/// Last turn state stored atomically with its frame. Stream publication
/// uses this durable value, never a state from buffered frames.
projected_turn: Option<TurnState>,
+ /// Publish the start of each live answer without waiting for the batch.
+ first_output: FirstOutput,
}
/// One frame waiting for the next write.
@@ -1335,11 +1345,16 @@ fn batches(content: &Message) -> bool {
/// Frames viewers must see as soon as they are stored rather than with the
/// next batch: anything the runtime will act on, and anything that projects
-/// onto the session's status.
+/// onto the session's status. Replies also unblock clients waiting for the
+/// handshake or a selected model/effort before sending their first prompt.
fn flushes_through(content: &Message) -> bool {
matches!(
content,
- Message::ToRuntime(_) | Message::ToServer(ToServerMessage::Event { .. })
+ Message::ToRuntime(_)
+ | Message::ToServer(ToServerMessage::Event { .. })
+ | Message::ToServer(ToServerMessage::Acp(AcpMessage(
+ RawJsonRpcMessage::Response(_)
+ )))
)
}
@@ -1363,6 +1378,7 @@ impl<R, Rt> LiveSessionLogWriter<R, Rt> {
flush_due: None,
projected_model: None,
projected_turn: None,
+ first_output: FirstOutput::default(),
}
}
@@ -1381,6 +1397,7 @@ impl<R, Rt> LiveSessionLogWriter<R, Rt> {
flush_due: None,
projected_model: None,
projected_turn: None,
+ first_output: FirstOutput::default(),
}
}
@@ -1433,11 +1450,12 @@ where
}
}
}
- let signals = self
+ let pushed = self
.fold
.as_mut()
- .map(|fold| fold.push(log.clone()).signals)
+ .map(|fold| fold.push(log.clone()))
.unwrap_or_default();
+ let first_output = self.first_output.observe(&pushed.events);
let turn_state = self
.fold
@@ -1501,6 +1519,10 @@ where
}
};
+ if first_output && let Some(deadline) = &mut self.flush_due {
+ *deadline = (*deadline).min(tokio::time::Instant::now() + FIRST_OUTPUT_FLUSH_INTERVAL);
+ }
+
if turn_state.is_some()
&& let Err(error) = self.realtime.publish_updated(session).await
{
@@ -1555,7 +1577,10 @@ where
}
}
- Ok(Appended { log_id, signals })
+ Ok(Appended {
+ log_id,
+ signals: pushed.signals,
+ })
}
async fn flush(&mut self) -> Result<()> {
diff --git a/crates/agent_session/src/domain/service/first_output.rs b/crates/agent_session/src/domain/service/first_output.rs
new file mode 100644
index 0000000000..a4e9b8e0fd
--- /dev/null
+++ b/crates/agent_session/src/domain/service/first_output.rs
@@ -0,0 +1,78 @@
+//! Which live frames should bypass the log's publication timer.
+
+use agent_fold::domain::model::{Author, Control, FoldEvent, MessagePart, OwnedFoldEvent, TurnId};
+
+/// Keep the beginning of prose responsive across small provider chunks. A
+/// numbered-list marker, bold delimiter, or code-fence language can arrive
+/// before any readable words; stopping at the first nonempty chunk strands
+/// those words behind the regular batching interval.
+const INITIAL_TEXT_CHARS: usize = 64;
+
+/// Publish the first output and a bounded burst of initial prose promptly.
+/// Subsequent chunks and replay retain the regular batching interval.
+#[derive(Default)]
+pub(super) struct FirstOutput {
+ turn: Option<TurnId>,
+ output_seen: bool,
+ text_chars: usize,
+}
+
+impl FirstOutput {
+ pub(super) fn observe(&mut self, events: &[OwnedFoldEvent]) -> bool {
+ let mut flush = false;
+ for event in events {
+ match event {
+ FoldEvent::NewMessage(message)
+ if matches!(message.author, Author::User { .. })
+ && message.parts.iter().any(|part| {
+ matches!(
+ part,
+ MessagePart::Text { .. }
+ | MessagePart::Attachment { .. }
+ | MessagePart::Control {
+ control: Control::Compact,
+ ..
+ }
+ )
+ }) =>
+ {
+ *self = Self {
+ turn: Some(message.id),
+ ..Self::default()
+ };
+ }
+ FoldEvent::NewMessage(message) | FoldEvent::MessageUpdate(message)
+ if matches!(message.author, Author::Agent)
+ && self.turn == Some(message.id)
+ && self.text_chars < INITIAL_TEXT_CHARS =>
+ {
+ let text_chars = message
+ .parts
+ .iter()
+ .filter_map(|part| match part {
+ MessagePart::Text { text } => Some(text.chars()),
+ _ => None,
+ })
+ .flatten()
+ .filter(|character| !character.is_whitespace())
+ .take(INITIAL_TEXT_CHARS)
+ .count();
+ let output = message.parts.iter().any(|part| match part {
+ MessagePart::Text { text } | MessagePart::Thought { text } => {
+ !text.trim().is_empty()
+ }
+ _ => true,
+ });
+ flush |= (!self.output_seen && output) || text_chars > self.text_chars;
+ self.output_seen |= output;
+ self.text_chars = text_chars;
+ }
+ // The fold stages session/load replay and replaces history at
+ // the boundary. Old answers must not trigger live flushes.
+ FoldEvent::MessagesReplaced(_) => *self = Self::default(),
+ _ => {}
+ }
+ }
+ flush
+ }
+}
diff --git a/crates/agent_session/src/domain/service/test.rs b/crates/agent_session/src/domain/service/test.rs
index 41b8e84979..aaf97a6594 100644
--- a/crates/agent_session/src/domain/service/test.rs
+++ b/crates/agent_session/src/domain/service/test.rs
@@ -23,6 +23,8 @@ use std::sync::{Arc, Mutex};
use tokio::sync::Notify;
use tracing::instrument::WithSubscriber as _;
+mod first_output;
+
struct Fixture {
service: AgentSessionServiceImpl<
InMemoryAgentSessionRepo,
diff --git a/crates/agent_session/src/domain/service/test/first_output.rs b/crates/agent_session/src/domain/service/test/first_output.rs
new file mode 100644
index 0000000000..7d29d8ef85
--- /dev/null
+++ b/crates/agent_session/src/domain/service/test/first_output.rs
@@ -0,0 +1,288 @@
+use super::*;
+use crate::domain::ports::AgentSessionLogWriter as _;
+use serde_json::json;
+
+async fn flush_start(logs: &mut LiveSessionLogWriter<InMemoryAgentSessionRepo, RecordingRealtime>) {
+ let deadline = logs.flush_deadline().expect("output schedules a flush");
+ assert!(deadline - tokio::time::Instant::now() <= std::time::Duration::from_millis(100));
+ tokio::time::sleep_until(deadline).await;
+ logs.flush().await.unwrap();
+}
+
+fn prompt(id: &str) -> AgentSessionLog {
+ parse_log_as(
+ test_session(),
+ &json!({"direction": "to_runtime", "content": {
+ "type": "acp", "jsonrpc": "2.0", "id": id, "method": "session/prompt",
+ "params": {"sessionId": "acp-1", "prompt": [{"type": "text", "text": "go"}]}
+ }})
+ .to_string(),
+ )
+ .remove(0)
+}
+
+fn chunk(kind: &str, text: &str) -> AgentSessionLog {
+ parse_log_as(
+ test_session(),
+ &json!({"direction": "to_server", "content": {
+ "type": "acp", "jsonrpc": "2.0", "method": "session/update",
+ "params": {"sessionId": "acp-1", "update": {
+ "sessionUpdate": kind, "content": {"type": "text", "text": text}
+ }}
+ }})
+ .to_string(),
+ )
+ .remove(0)
+}
+
+#[tokio::test]
+async fn runtime_replies_publish_pending_frames_and_configuration_immediately() {
+ let realtime = RecordingRealtime::new();
+ let (repo, mut logs) = fenced_connection(realtime.clone()).await;
+ let buffered = logs
+ .append(chunk("agent_thought_chunk", "pending"))
+ .await
+ .unwrap();
+ let response = parse_log_as(
+ test_session(),
+ &json!({
+ "direction": "to_server", "content": {
+ "type": "acp", "jsonrpc": "2.0", "id": "config", "result": {"configOptions": []}
+ }
+ })
+ .to_string(),
+ )
+ .remove(0);
+ let replied = logs.append(response).await.unwrap();
+ let stored = AgentSessionLogRepo::list_by_session(&repo, test_session())
+ .await
+ .unwrap();
+ assert_eq!(
+ stored.iter().map(|e| e.id).collect::<Vec<_>>(),
+ vec![buffered.log_id, replied.log_id]
+ );
+ let published = realtime.published();
+ assert_eq!(published.len(), 1);
+ assert_eq!(
+ published[0]
+ .entries
+ .iter()
+ .map(|e| e.id)
+ .collect::<Vec<_>>(),
+ vec![buffered.log_id, replied.log_id]
+ );
+ assert!(logs.flush_deadline().is_none());
+}
+
+#[tokio::test(start_paused = true)]
+async fn first_thought_and_first_text_publish_before_the_regular_batch_deadline() {
+ let realtime = RecordingRealtime::new();
+ let (repo, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ let first = logs
+ .append(chunk("agent_thought_chunk", "Thinking"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ assert_eq!(realtime.published().len(), 2);
+ assert_eq!(realtime.published()[1].entries[0].id, first.log_id);
+ assert!(logs.flush_deadline().is_none());
+
+ let next = logs
+ .append(chunk("agent_thought_chunk", " more"))
+ .await
+ .unwrap();
+ assert_eq!(
+ realtime.published().len(),
+ 2,
+ "later thoughts remain batched"
+ );
+ let text = logs
+ .append(chunk("agent_message_chunk", "The answer has enough words to fill the initial text batch before later chunks arrive."))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ let published = realtime.published();
+ assert_eq!(published.len(), 3);
+ assert_eq!(
+ published[2]
+ .entries
+ .iter()
+ .map(|e| e.id)
+ .collect::<Vec<_>>(),
+ vec![next.log_id, text.log_id]
+ );
+ let stored = AgentSessionLogRepo::list_by_session(&repo, test_session())
+ .await
+ .unwrap();
+ assert_eq!(
+ stored.last().unwrap().id,
+ text.log_id,
+ "publish follows the durable write"
+ );
+
+ logs.append(chunk("agent_message_chunk", " continues"))
+ .await
+ .unwrap();
+ assert_eq!(realtime.published().len(), 3, "later prose remains batched");
+ assert!(logs.flush_deadline().is_some());
+
+ logs.append(prompt("second")).await.unwrap();
+ let second = logs
+ .append(chunk("agent_message_chunk", "Next answer"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ assert_eq!(
+ realtime.published().len(),
+ 5,
+ "a new prompt resets both milestones"
+ );
+ assert_eq!(realtime.published()[4].entries[0].id, second.log_id);
+ assert!(logs.flush_deadline().is_none());
+}
+
+#[tokio::test(start_paused = true)]
+async fn empty_chunks_do_not_consume_the_first_output_flush() {
+ let realtime = RecordingRealtime::new();
+ let (_, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ logs.append(chunk("agent_thought_chunk", " "))
+ .await
+ .unwrap();
+ logs.append(chunk("agent_message_chunk", "\n"))
+ .await
+ .unwrap();
+ assert_eq!(realtime.published().len(), 1);
+ let text = logs
+ .append(chunk("agent_message_chunk", "Visible"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ let published = realtime.published();
+ assert_eq!(published.len(), 2);
+ assert_eq!(published[1].entries.last().unwrap().id, text.log_id);
+ assert!(logs.flush_deadline().is_none());
+}
+
+#[tokio::test(start_paused = true)]
+async fn changing_model_during_a_turn_does_not_delay_its_first_prose() {
+ let realtime = RecordingRealtime::new();
+ let (_, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ logs.append(chunk("agent_thought_chunk", "Thinking"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ let control = parse_log_as(test_session(), &json!({
+ "direction": "to_runtime", "content": {
+ "type": "acp", "jsonrpc": "2.0", "id": "config", "method": "session/set_config_option",
+ "params": {"sessionId": "acp-1", "configId": "model", "value": "new-model"}
+ }
+ }).to_string()).remove(0);
+ logs.append(control).await.unwrap();
+ assert_eq!(realtime.published().len(), 3);
+ let text = logs
+ .append(chunk("agent_message_chunk", "The answer"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ let published = realtime.published();
+ assert_eq!(published.len(), 4);
+ assert_eq!(published[3].entries[0].id, text.log_id);
+ assert!(logs.flush_deadline().is_none());
+}
+
+#[tokio::test]
+async fn first_output_cannot_bypass_a_superseded_fence() {
+ let realtime = RecordingRealtime::new();
+ let (repo, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ repo.release(logs.claim.as_ref().unwrap()).await.unwrap();
+ let _successor = claim_for_test(&repo, test_session()).await;
+ logs.append(chunk("agent_message_chunk", "Stale"))
+ .await
+ .unwrap();
+ assert!(matches!(
+ logs.flush().await,
+ Err(AgentSessionError::FencedOut(_))
+ ));
+ assert_eq!(
+ realtime.published().len(),
+ 1,
+ "uncommitted output is never published"
+ );
+}
+
+#[tokio::test(start_paused = true)]
+async fn markdown_prefix_and_words_share_the_early_batch_without_extending_its_deadline() {
+ let realtime = RecordingRealtime::new();
+ let (_, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ let prefix = logs
+ .append(chunk("agent_message_chunk", "**"))
+ .await
+ .unwrap();
+ let deadline = logs.flush_deadline();
+ tokio::time::advance(std::time::Duration::from_millis(10)).await;
+ let words = logs
+ .append(chunk("agent_message_chunk", "Sunlight**"))
+ .await
+ .unwrap();
+ assert_eq!(
+ logs.flush_deadline(),
+ deadline,
+ "subsequent chunks cannot postpone the initial flush"
+ );
+ assert_eq!(realtime.published().len(), 1);
+ flush_start(&mut logs).await;
+ let published = realtime.published();
+ assert_eq!(published.len(), 2);
+ assert_eq!(
+ published[1]
+ .entries
+ .iter()
+ .map(|e| e.id)
+ .collect::<Vec<_>>(),
+ vec![prefix.log_id, words.log_id]
+ );
+}
+
+#[tokio::test(start_paused = true)]
+async fn words_arriving_after_a_prefix_was_published_still_get_an_early_flush() {
+ let realtime = RecordingRealtime::new();
+ let (_, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ logs.append(chunk("agent_message_chunk", "1. **"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ assert_eq!(realtime.published().len(), 2);
+ tokio::time::advance(std::time::Duration::from_millis(100)).await;
+ let words = logs
+ .append(chunk("agent_message_chunk", "Sunlight**"))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ let published = realtime.published();
+ assert_eq!(published.len(), 3);
+ assert_eq!(published[2].entries[0].id, words.log_id);
+}
+
+#[tokio::test(start_paused = true)]
+async fn reasoning_after_short_prose_does_not_keep_triggering_early_flushes() {
+ let realtime = RecordingRealtime::new();
+ let (_, mut logs) = fenced_connection(realtime.clone()).await;
+ logs.append(prompt("first")).await.unwrap();
+ logs.append(chunk("agent_message_chunk", "Checking."))
+ .await
+ .unwrap();
+ flush_start(&mut logs).await;
+ logs.append(chunk("agent_thought_chunk", "Thinking more"))
+ .await
+ .unwrap();
+ assert!(
+ logs.flush_deadline().unwrap() - tokio::time::Instant::now()
+ >= std::time::Duration::from_secs(1)
+ );
+}
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 0ce539d5cd..007608e83e 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -5,6 +5,16 @@ User-sent messages in chat and agent transcripts use an ink-colored bubble with
lighter bubble with the normal text palette. Preview Markdown and controls at
`/app/debug/ui?ui=invert-util` under **User-sent AI message**.
+## Checking first-response latency
+
+From outside an editor, press `c`, then `a`, type a prompt, and press Enter.
+Repeat with the default model and with an explicit model/effort selection.
+The first visible output and the first answer text should appear as they arrive;
+later chunks can arrive in batches. Reasoning or a tool row should not delay the
+first prose. Verify a second prompt and a reload preserve the complete answer.
+Selected model and effort must be confirmed before the first prompt; settings
+already confirmed by the runtime do not need another control request.
+
## Working with projects
Project tools can list, read, create, update, delete, and share projects, and
diff --git a/services/agent_harness_service/src/config.rs b/services/agent_harness_service/src/config.rs
index 2f9b4cf2cf..81934de0d3 100644
--- a/services/agent_harness_service/src/config.rs
+++ b/services/agent_harness_service/src/config.rs
@@ -158,9 +158,8 @@ pub struct Config {
/// Repository sessions run against, until it becomes per-request data.
#[macro_config_default(String::from("https://github.com/macro-inc/macro"))]
pub harness_repo_url: String,
- /// Model id stamped onto sessions the in-memory bot opens. Unknown ids
- /// fall back to the agent loop's default model.
- #[macro_config_default(String::from("claude-sonnet-5-5"))]
+ /// Provider-qualified model id stamped onto sessions the in-memory bot opens.
+ #[macro_config_default(String::from("anthropic/claude-sonnet-5-5"))]
pub inmem_model: String,
/// Harness slug stamped onto sessions the in-memory bot opens.
#[macro_config_default(String::from("macro-inmem"))]