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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.18

- Counted subagent model calls in turn and session token totals, including parallel dispatches.

## 0.3.17

- Surfaced malformed plugin marketplace index JSON and fetch failures instead of treating them as an empty index.
Expand Down
2 changes: 1 addition & 1 deletion rv.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rook"
version = "0.3.17"
version = "0.3.18"
edition = "v2"

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions src/agent/subturn.rv
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fun run_subagent(
Ok(reply) -> {
reply_text = reply.content
calls = reply.tool_calls
st.add_usage(reply.usage.prompt_tokens, reply.usage.completion_tokens)
},
Err(e) -> {
err = e.message
Expand Down
9 changes: 7 additions & 2 deletions src/agent/subturn_e2e_test.rv
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ fun sub_read_handler(req: Request) -> Response {
read_hits = read_hits + 1
if read_hits == 1 {
return Response.text(
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"\",\"tool_calls\":[{\"id\":\"s1\",\"type\":\"function\",\"function\":{\"name\":\"read_file\",\"arguments\":\"{\\\"path\\\":\\\"_rook_sub.txt\\\"}\"}}]},\"finish_reason\":\"tool_calls\"}]}",
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"\",\"tool_calls\":[{\"id\":\"s1\",\"type\":\"function\",\"function\":{\"name\":\"read_file\",\"arguments\":\"{\\\"path\\\":\\\"_rook_sub.txt\\\"}\"}}]},\"finish_reason\":\"tool_calls\"}],\"usage\":{\"prompt_tokens\":11,\"completion_tokens\":3}}",
)
}
return Response.text(
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"The notes say ship it.\"},\"finish_reason\":\"stop\"}]}",
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"The notes say ship it.\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":13,\"completion_tokens\":5}}",
)
}

Expand Down Expand Up @@ -83,7 +83,12 @@ fun test_subagent_runs_a_tool_round_and_returns_only_the_answer() {
// The parent conversation stayed clean; the tool activity surfaced as a
// labeled display event.
assert_eq_int(st.messages().len(), 0)
let tokens = st.turn_tokens()
assert_eq_int(tokens.prompt, 24)
assert_eq_int(tokens.completion, 8)
let snap = st.drain()
assert_eq_int(snap.sess_prompt, 24)
assert_eq_int(snap.sess_completion, 8)
let seen = ""
let i = 0
while i < snap.events.len() {
Expand Down
8 changes: 6 additions & 2 deletions src/agent/turn_e2e_test.rv
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ fun serve_dispatch() {
fun fanout_handler(req: Request) -> Response {
if req.body.contains("echo agent") {
return Response.text(
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"echo done\"},\"finish_reason\":\"stop\"}]}",
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"echo done\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":40,\"completion_tokens\":4}}",
)
}
if req.body.contains("shout agent") {
return Response.text(
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"SHOUT DONE\"},\"finish_reason\":\"stop\"}]}",
"{\"choices\":[{\"message\":{\"role\":\"assistant\",\"content\":\"SHOUT DONE\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":60,\"completion_tokens\":6}}",
)
}
fanout_hits = fanout_hits + 1
Expand Down Expand Up @@ -322,6 +322,10 @@ fun test_two_dispatches_fan_out_and_both_results_return() {
assert_true(got.contains("[dispatch(echoer) => echo done]"))
assert_true(got.contains("[dispatch(shouter) => SHOUT DONE]"))
assert_true(got.contains("Both agents reported."))
assert_true(got.contains("[info turn: 110 tok]"))
let usage = st.turn_tokens()
assert_eq_int(usage.prompt, 100)
assert_eq_int(usage.completion, 10)
// user, assistant(two tool_calls), two tool_results, assistant(final).
let msgs = st.messages()
assert_eq_int(msgs.len(), 5)
Expand Down
Loading