Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions crates/dim-agent-capabilities/src/timeline_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3343,7 +3343,7 @@ impl LineView {
}
}
/// `<dim-branch-line>`, written by TimelineTree at the start of every child.
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#;
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#;

/// `<dim-branch-lines>`, the roster BranchLine writes under [`roster_key`] on
/// a line that opened lines.
Expand Down Expand Up @@ -5229,10 +5229,7 @@ impl BranchTool {
call_id: &str,
) -> std::result::Result<ToolResult, HostError> {
if own.role != LineRole::Tool {
return Ok(refusal(
"branch_cannot_end",
"Only a line opened with create can end itself.".into(),
));
return Ok(refusal("branch_cannot_end", CANNOT_END_TEXT.into()));
}
if own.ending {
return Ok(self.ended(&own.id));
Expand All @@ -5259,6 +5256,10 @@ impl BranchTool {
own.id, parent
))),
Err(AgentError::BranchEnded(line)) => Ok(self.ended(&line)),
Err(AgentError::BranchRefused {
refusal: BranchRefusal::CannotEnd,
..
}) => Ok(refusal("branch_cannot_end", CANNOT_END_TEXT.into())),
Err(AgentError::BranchRefused {
refusal: kind,
message,
Expand Down Expand Up @@ -5850,6 +5851,10 @@ fn status_note(
/// The `branch` tool's refusal of `create` on a line that is neither the root
/// nor the default branch (design §4, §11).
const NOT_OPENER_TEXT: &str = "Only the root and the default branch open lines. Tell one of them if more parallel work is needed.";
/// The `branch` tool's refusal of `end` on the root, the default branch, a
/// plugin line, a line the user opened or an ancestor of the default branch
/// (design §10, §11).
const CANNOT_END_TEXT: &str = "Only a line opened with create can end itself, and not while it or a line below it is the default branch.";
/// The `branch` tool's refusal of `create` when the open would cross the
/// Session's cap of open tool lines (design §6.1, §11).
const LIMIT_REACHED_TEXT: &str = "This Session holds its limit of open lines. Continue on this line, or end one of its open lines first.";
Expand Down
16 changes: 8 additions & 8 deletions crates/dim-agent-capabilities/tests/branch_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3863,14 +3863,14 @@ async fn a_refused_branch_call_writes_nothing() {
call(&session, "main", r#"{"action":"end","content":"done"}"#).await,
(
"branch_cannot_end".into(),
"Only a line opened with create can end itself.".into()
"Only a line opened with create can end itself, and not while it or a line below it is the default branch.".into()
)
);
assert_eq!(
call(&session, &host, r#"{"action":"end","content":"done"}"#).await,
(
"branch_cannot_end".into(),
"Only a line opened with create can end itself.".into()
"Only a line opened with create can end itself, and not while it or a line below it is the default branch.".into()
)
);
assert!(
Expand Down Expand Up @@ -4547,7 +4547,7 @@ async fn a_configured_description_reaches_the_request_declaration() {
/// its guide entry is registered there, at the Session, and a line carries it
/// even where no branch part is loaded. `<dim-branch-lines>` stays with
/// BranchLine, which writes the roster.
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#;
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#;
const ROSTER_ENTRY: &str = r#"<dim-branch-lines branch="main">: the lines you opened, under the key `branch:roster` and apart from your own identity under `branch:line`: the runtime lists the tool lines you opened that are still open, each with the first line of its purpose. A later block of this name replaces the earlier one; it is state about the lines, not a request."#;
/// #987: the parent block can arrive only on a line with a parent, so main's
/// guide carries no entry for it.
Expand Down Expand Up @@ -5988,7 +5988,7 @@ async fn a_nested_line_is_told_its_own_parent_at_open() {
.submit(text, InputMode::Queue, &inner)
.await
.unwrap();
soon(session.idle(&inner)).await.unwrap();
patient(session.idle(&inner)).await.unwrap();
}
let message = baseline_message(&local_events(&session, &inner).await, "branch:parent")
.expect("the line compacted and its parent block replayed");
Expand Down Expand Up @@ -6458,7 +6458,7 @@ async fn the_parent_block_replays_after_a_compaction() {
.submit(text, InputMode::Queue, &child)
.await
.unwrap();
soon(session.idle(&child)).await.unwrap();
patient(session.idle(&child)).await.unwrap();
}
let message = baseline_message(&local_events(&session, &child).await, "branch:parent")
.expect("the line compacted and its parent block replayed");
Expand Down Expand Up @@ -7634,7 +7634,7 @@ async fn wait_for_roster(session: &Session, line: &str) {
async fn compact_line(session: &Session, line: &str) {
for text in ["x".repeat(1500), "y".repeat(1500)] {
session.submit(text, InputMode::Queue, line).await.unwrap();
soon(session.idle(line)).await.unwrap();
patient(session.idle(line)).await.unwrap();
}
}

Expand Down Expand Up @@ -9564,7 +9564,7 @@ async fn a_switched_line_keeps_its_identity_after_a_compaction() {
.unwrap();
for text in ["x".repeat(1500), "y".repeat(1500)] {
session.submit(text, InputMode::Queue, &line).await.unwrap();
soon(session.idle(&line)).await.unwrap();
patient(session.idle(&line)).await.unwrap();
}
let note = line_block(&chain_events(&session, &line, ..).await.unwrap())
.expect("the note is the latest block of the key");
Expand Down Expand Up @@ -9645,7 +9645,7 @@ async fn a_multi_paragraph_purpose_survives_a_move_and_a_compaction() {
);
for text in ["x".repeat(1500), "y".repeat(1500)] {
session.submit(text, InputMode::Queue, &line).await.unwrap();
soon(session.idle(&line)).await.unwrap();
patient(session.idle(&line)).await.unwrap();
}
let note = line_block(&chain_events(&session, &line, ..).await.unwrap())
.expect("the note is still the latest block of the key");
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/minimal_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn tool_results(events: &[Arc<AgentEvent>]) -> usize {
}

/// #552: the entry TimelineTree registers for `<dim-branch-line>`.
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#;
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#;

fn system_text(prompt: &SystemPrompt) -> String {
match prompt {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/prompt_guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const CHANNEL_RULE: &str = "The operator is the person running this session. The
const PROBE_ENTRY: &str = r#"<dim-probe source="test">: an entry a contributor registered for this flow; the composition places it between the state and the rule entries."#;

/// #552: TimelineTree writes `<dim-branch-line>` and registers its entry.
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; it is state about the line, not a request."#;
const IDENTITY_ENTRY: &str = r#"<dim-branch-line branch="C" parent="main" source="tool">: which line of this session you are, placed by the runtime at the start of a line's own history. A later block of this name replaces the earlier one; a block carrying `default` is the note a move writes. Both are state about the line, not requests."#;
/// #552: BranchLine writes `<dim-branch-lines>` and registers its entry.
const ROSTER_ENTRY: &str = r#"<dim-branch-lines branch="main">: the lines you opened, under the key `branch:roster` and apart from your own identity under `branch:line`: the runtime lists the tool lines you opened that are still open, each with the first line of its purpose. A later block of this name replaces the earlier one; it is state about the lines, not a request."#;

Expand Down