|
1
|
+ |
defmodule OpenAgentsWeb.ChatConsoleTest do
|
|
2
|
+ |
@moduledoc """
|
|
3
|
+ |
`/chat` is the operator-only Ox Alpha console.
|
|
4
|
+ |
|
|
5
|
+ |
The gate is worth its own file because it fails in two quiet directions: a
|
|
6
|
+ |
missing plug lets a signed-in non-operator read the page, and a missing
|
|
7
|
+ |
on_mount hook lets a LiveView event run on a socket that never passed the
|
|
8
|
+ |
gate. The turn states carry the rest of the file: an empty console, a turn in
|
|
9
|
+ |
flight, a completed turn with the evidence the provider reported, a stopped
|
|
10
|
+ |
turn, and a failed turn whose prompt survives.
|
|
11
|
+ |
"""
|
|
12
|
+ |
|
|
13
|
+ |
use OpenAgentsWeb.ConnCase
|
|
14
|
+ |
import Phoenix.LiveViewTest
|
|
15
|
+ |
|
|
16
|
+ |
alias OpenAgents.Chat.AccountTurns
|
|
17
|
+ |
|
|
18
|
+ |
# The console streams through OpenRouter. These tests replace that function so
|
|
19
|
+ |
# a turn reaches its states without a provider.
|
|
20
|
+ |
defp stub_streamer(streamer) do
|
|
21
|
+ |
Application.put_env(:openagents, :chat_console_streamer, streamer)
|
|
22
|
+ |
on_exit(fn -> Application.delete_env(:openagents, :chat_console_streamer) end)
|
|
23
|
+ |
end
|
|
24
|
+ |
|
|
25
|
+ |
test "an anonymous request is sent home", %{conn: conn} do
|
|
26
|
+ |
conn = get(conn, ~p"/chat")
|
|
27
|
+ |
|
|
28
|
+ |
assert redirected_to(conn) == ~p"/"
|
|
29
|
+ |
end
|
|
30
|
+ |
|
|
31
|
+ |
test "a signed-in non-operator is sent home", %{conn: conn} do
|
|
32
|
+ |
conn = log_in_github_user(conn, "not-an-operator")
|
|
33
|
+ |
conn = get(conn, ~p"/chat")
|
|
34
|
+ |
|
|
35
|
+ |
assert redirected_to(conn) == ~p"/"
|
|
36
|
+ |
end
|
|
37
|
+ |
|
|
38
|
+ |
test "an operator gets the empty console", %{conn: conn} do
|
|
39
|
+ |
conn = log_in_admin_user(conn, "console-operator")
|
|
40
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
41
|
+ |
|
|
42
|
+ |
assert has_element?(view, "#chat-console-transcript")
|
|
43
|
+ |
assert has_element?(view, "#chat-console-empty")
|
|
44
|
+ |
assert has_element?(view, "#chat-console-model", "Ox Alpha")
|
|
45
|
+ |
assert has_element?(view, "#chat-console-operator-notice", "Operator-only console")
|
|
46
|
+ |
assert has_element?(view, "#chat-console-suggestions")
|
|
47
|
+ |
assert has_element?(view, "#chat-console-suggestion-0")
|
|
48
|
+ |
assert has_element?(view, ~s(a[href="/sarah"]))
|
|
49
|
+ |
assert has_element?(view, ~s(#chat-console-form[data-submit-on-enter="true"]))
|
|
50
|
+ |
assert has_element?(view, ~s(#chat-console-form[data-clear-event="chat-console:clear"]))
|
|
51
|
+ |
assert has_element?(view, ~s(#chat_message[phx-mounted]))
|
|
52
|
+ |
assert has_element?(view, ~s(#chat_reasoning[name="chat[reasoning]"]))
|
|
53
|
+ |
assert has_element?(view, "#chat-console-submit")
|
|
54
|
+ |
end
|
|
55
|
+ |
|
|
56
|
+ |
test "a suggestion fills the composer", %{conn: conn} do
|
|
57
|
+ |
conn = log_in_admin_user(conn, "console-suggestion-operator")
|
|
58
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
59
|
+ |
|
|
60
|
+ |
html = view |> element("#chat-console-suggestion-0") |> render_click()
|
|
61
|
+ |
|
|
62
|
+ |
assert html =~ "Ox Alpha stress fleet measures"
|
|
63
|
+ |
end
|
|
64
|
+ |
|
|
65
|
+ |
test "a turn in flight can be stopped", %{conn: conn} do
|
|
66
|
+ |
stub_streamer(fn _request, callback, _options ->
|
|
67
|
+ |
callback.({:text_delta, "Working"})
|
|
68
|
+ |
|
|
69
|
+ |
receive do
|
|
70
|
+ |
:never -> {:ok, %{}}
|
|
71
|
+ |
end
|
|
72
|
+ |
end)
|
|
73
|
+ |
|
|
74
|
+ |
conn = log_in_admin_user(conn, "console-streaming-operator")
|
|
75
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
76
|
+ |
|
|
77
|
+ |
view
|
|
78
|
+ |
|> form("#chat-console-form", %{"chat" => %{"message" => "Stress the fleet."}})
|
|
79
|
+ |
|> render_submit()
|
|
80
|
+ |
|
|
81
|
+ |
assert has_element?(view, "#chat-console-streaming-assistant-message")
|
|
82
|
+ |
assert has_element?(view, ~s(#chat-console-submit[aria-label="Stop response"]))
|
|
83
|
+ |
|
|
84
|
+ |
view |> element("#chat-console-submit") |> render_click()
|
|
85
|
+ |
|
|
86
|
+ |
refute has_element?(view, "#chat-console-streaming-assistant-message")
|
|
87
|
+ |
assert has_element?(view, ~s([id^="chat-console-cancelled-"]), "You stopped this response")
|
|
88
|
+ |
end
|
|
89
|
+ |
|
|
90
|
+ |
test "a completed turn shows the evidence the provider reported", %{conn: conn} do
|
|
91
|
+ |
key = "console-completed-operator"
|
|
92
|
+ |
user = github_user(key)
|
|
93
|
+ |
conn = log_in_admin_user(conn, key)
|
|
94
|
+ |
|
|
95
|
+ |
streamer = fn _request, callback, _options ->
|
|
96
|
+ |
callback.({:text_delta, "The fleet is idle."})
|
|
97
|
+ |
|
|
98
|
+ |
{:ok,
|
|
99
|
+ |
%{
|
|
100
|
+ |
"object" => "chat.completion",
|
|
101
|
+ |
"model" => "stealth/ox-alpha",
|
|
102
|
+ |
"assistant_content" => "The fleet is idle.",
|
|
103
|
+ |
"provider" => "Stealth",
|
|
104
|
+ |
"request_id" => "gen-123",
|
|
105
|
+ |
"usage" => %{
|
|
106
|
+ |
"prompt_tokens" => 24,
|
|
107
|
+ |
"completion_tokens" => 8,
|
|
108
|
+ |
"total_tokens" => 32,
|
|
109
|
+ |
"completion_tokens_details" => %{"reasoning_tokens" => 3},
|
|
110
|
+ |
"prompt_tokens_details" => %{"cached_tokens" => 4}
|
|
111
|
+ |
}
|
|
112
|
+ |
}}
|
|
113
|
+ |
end
|
|
114
|
+ |
|
|
115
|
+ |
assert {:ok, %{"id" => run_id}} =
|
|
116
|
+ |
AccountTurns.submit(user, "Report the fleet.",
|
|
117
|
+ |
subscriber: self(),
|
|
118
|
+ |
streamer: streamer
|
|
119
|
+ |
)
|
|
120
|
+ |
|
|
121
|
+ |
assert_receive {:account_chat_completed, ^run_id, {:ok, _completion}}
|
|
122
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
123
|
+ |
|
|
124
|
+ |
metadata = "#chat-console-response-metadata-#{run_id}"
|
|
125
|
+ |
assert has_element?(view, metadata, "Ox Alpha")
|
|
126
|
+ |
assert has_element?(view, metadata, "lane Stealth")
|
|
127
|
+ |
assert has_element?(view, metadata, "request gen-123")
|
|
128
|
+ |
assert has_element?(view, metadata, "ms")
|
|
129
|
+ |
assert has_element?(view, "#chat-console-usage-#{run_id}", "Input 24")
|
|
130
|
+ |
assert has_element?(view, "#chat-console-usage-#{run_id}", "Output 8")
|
|
131
|
+ |
assert has_element?(view, "#chat-console-usage-#{run_id}", "Reasoning 3")
|
|
132
|
+ |
assert has_element?(view, "#chat-console-usage-#{run_id}", "Cached 4")
|
|
133
|
+ |
refute has_element?(view, "#chat-console-evidence-#{run_id}")
|
|
134
|
+ |
end
|
|
135
|
+ |
|
|
136
|
+ |
test "a completed turn shows a context meter where a window is configured", %{conn: conn} do
|
|
137
|
+ |
key = "console-context-operator"
|
|
138
|
+ |
user = github_user(key)
|
|
139
|
+ |
conn = log_in_admin_user(conn, key)
|
|
140
|
+ |
Application.put_env(:openagents, :openrouter_context_window, 128_000)
|
|
141
|
+ |
on_exit(fn -> Application.put_env(:openagents, :openrouter_context_window, nil) end)
|
|
142
|
+ |
|
|
143
|
+ |
streamer = fn _request, _callback, _options ->
|
|
144
|
+ |
{:ok,
|
|
145
|
+ |
%{
|
|
146
|
+ |
"assistant_content" => "Done.",
|
|
147
|
+ |
"usage" => %{"total_tokens" => 640, "prompt_tokens" => 600, "completion_tokens" => 40}
|
|
148
|
+ |
}}
|
|
149
|
+ |
end
|
|
150
|
+ |
|
|
151
|
+ |
assert {:ok, %{"id" => run_id}} =
|
|
152
|
+ |
AccountTurns.submit(user, "Measure the window.",
|
|
153
|
+ |
subscriber: self(),
|
|
154
|
+ |
streamer: streamer
|
|
155
|
+ |
)
|
|
156
|
+ |
|
|
157
|
+ |
assert_receive {:account_chat_completed, ^run_id, {:ok, _completion}}
|
|
158
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
159
|
+ |
|
|
160
|
+ |
assert has_element?(view, "#chat-console-evidence-#{run_id}")
|
|
161
|
+ |
end
|
|
162
|
+ |
|
|
163
|
+ |
test "a rate-limited turn is retryable", %{conn: conn} do
|
|
164
|
+ |
key = "console-retry-operator"
|
|
165
|
+ |
user = github_user(key)
|
|
166
|
+ |
conn = log_in_admin_user(conn, key)
|
|
167
|
+ |
|
|
168
|
+ |
streamer = fn _request, _callback, _options -> {:error, :rate_limited} end
|
|
169
|
+ |
|
|
170
|
+ |
assert {:ok, %{"id" => run_id}} =
|
|
171
|
+ |
AccountTurns.submit(user, "Retry me.", subscriber: self(), streamer: streamer)
|
|
172
|
+ |
|
|
173
|
+ |
assert_receive {:account_chat_completed, ^run_id, {:error, :rate_limited}}
|
|
174
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
175
|
+ |
|
|
176
|
+ |
assert has_element?(view, "#chat-console-error-#{run_id}", "rate-limited")
|
|
177
|
+ |
assert has_element?(view, ~s(#chat-console-error-#{run_id}[role="alert"]))
|
|
178
|
+ |
|
|
179
|
+ |
assert has_element?(
|
|
180
|
+ |
view,
|
|
181
|
+ |
~s(#chat-console-retry-#{run_id}[phx-value-prompt="Retry me."])
|
|
182
|
+ |
)
|
|
183
|
+ |
end
|
|
184
|
+ |
|
|
185
|
+ |
test "a malformed provider stream is retryable", %{conn: conn} do
|
|
186
|
+ |
key = "console-malformed-operator"
|
|
187
|
+ |
user = github_user(key)
|
|
188
|
+ |
conn = log_in_admin_user(conn, key)
|
|
189
|
+ |
|
|
190
|
+ |
streamer = fn _request, _callback, _options -> {:error, :invalid_response} end
|
|
191
|
+ |
|
|
192
|
+ |
assert {:ok, %{"id" => run_id}} =
|
|
193
|
+ |
AccountTurns.submit(user, "Send a broken event.",
|
|
194
|
+ |
subscriber: self(),
|
|
195
|
+ |
streamer: streamer
|
|
196
|
+ |
)
|
|
197
|
+ |
|
|
198
|
+ |
assert_receive {:account_chat_completed, ^run_id, {:error, :invalid_response}}
|
|
199
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
200
|
+ |
|
|
201
|
+ |
assert has_element?(view, "#chat-console-error-#{run_id}")
|
|
202
|
+ |
assert has_element?(view, "#chat-console-retry-#{run_id}")
|
|
203
|
+ |
end
|
|
204
|
+ |
|
|
205
|
+ |
test "the composer shows a safe inline error when OpenRouter is not configured", %{conn: conn} do
|
|
206
|
+ |
conn = log_in_admin_user(conn, "console-composer-operator")
|
|
207
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
208
|
+ |
|
|
209
|
+ |
view
|
|
210
|
+ |
|> form("#chat-console-form", %{"chat" => %{"message" => "Draft the release notes."}})
|
|
211
|
+ |
|> render_submit()
|
|
212
|
+ |
|
|
213
|
+ |
assert has_element?(
|
|
214
|
+ |
view,
|
|
215
|
+ |
~s([data-message-role="user"]),
|
|
216
|
+ |
"Draft the release notes."
|
|
217
|
+ |
)
|
|
218
|
+ |
|
|
219
|
+ |
assert has_element?(view, ~s([role="alert"]), "OpenRouter is not configured")
|
|
220
|
+ |
assert has_element?(view, ~s(#chat_message), "Draft the release notes.")
|
|
221
|
+ |
end
|
|
222
|
+ |
|
|
223
|
+ |
test "a non-operator on a live socket is still turned away by the mount hook", %{conn: conn} do
|
|
224
|
+ |
# The plug gate runs on the initial document request; this drives the
|
|
225
|
+ |
# LiveView mount directly so the on_mount hook is what answers.
|
|
226
|
+ |
conn = log_in_chatting_user(conn, "socket-not-an-operator")
|
|
227
|
+ |
|
|
228
|
+ |
assert {:error, {:redirect, %{to: "/"}}} = live(conn, ~p"/chat")
|
|
229
|
+ |
end
|
|
230
|
+ |
|
|
231
|
+ |
test "reasoning stays interleaved with successive tool attempts" do
|
|
232
|
+ |
socket =
|
|
233
|
+ |
%Phoenix.LiveView.Socket{}
|
|
234
|
+ |
|> Phoenix.Component.assign(:stream_id, 42)
|
|
235
|
+ |
|> Phoenix.Component.assign(:streaming?, true)
|
|
236
|
+ |
|> Phoenix.Component.assign(:assistant_reasoning, nil)
|
|
237
|
+ |
|> Phoenix.Component.assign(:assistant_tool_calls, [])
|
|
238
|
+ |
|> Phoenix.Component.assign(:assistant_blocks, [])
|
|
239
|
+ |
|
|
240
|
+ |
{:noreply, socket} =
|
|
241
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
242
|
+ |
{:openrouter_stream_event, 42, {:reasoning_delta, "First attempt."}},
|
|
243
|
+ |
socket
|
|
244
|
+ |
)
|
|
245
|
+ |
|
|
246
|
+ |
{:noreply, socket} =
|
|
247
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
248
|
+ |
{:openrouter_stream_event, 42,
|
|
249
|
+ |
{:tool_call_started,
|
|
250
|
+ |
%{
|
|
251
|
+ |
"call_id" => "call-1",
|
|
252
|
+ |
"name" => "read_repository_file",
|
|
253
|
+ |
"arguments" => ~s({"path":"null"})
|
|
254
|
+ |
}}},
|
|
255
|
+ |
socket
|
|
256
|
+ |
)
|
|
257
|
+ |
|
|
258
|
+ |
{:noreply, socket} =
|
|
259
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
260
|
+ |
{:openrouter_stream_event, 42,
|
|
261
|
+ |
{:tool_call_failed, %{"call_id" => "call-1", "error" => "Not found"}}},
|
|
262
|
+ |
socket
|
|
263
|
+ |
)
|
|
264
|
+ |
|
|
265
|
+ |
{:noreply, socket} =
|
|
266
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
267
|
+ |
{:openrouter_stream_event, 42, {:reasoning_delta, "Second attempt."}},
|
|
268
|
+ |
socket
|
|
269
|
+ |
)
|
|
270
|
+ |
|
|
271
|
+ |
{:noreply, socket} =
|
|
272
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
273
|
+ |
{:openrouter_stream_event, 42,
|
|
274
|
+ |
{:tool_call_started,
|
|
275
|
+ |
%{
|
|
276
|
+ |
"call_id" => "call-2",
|
|
277
|
+ |
"name" => "read_repository_file",
|
|
278
|
+ |
"arguments" => ~s({"path":"README.md"})
|
|
279
|
+ |
}}},
|
|
280
|
+ |
socket
|
|
281
|
+ |
)
|
|
282
|
+ |
|
|
283
|
+ |
{:noreply, socket} =
|
|
284
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
285
|
+ |
{:openrouter_stream_event, 42,
|
|
286
|
+ |
{:tool_call_failed, %{"call_id" => "call-2", "error" => "Still not found"}}},
|
|
287
|
+ |
socket
|
|
288
|
+ |
)
|
|
289
|
+ |
|
|
290
|
+ |
{:noreply, socket} =
|
|
291
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
292
|
+ |
{:openrouter_stream_event, 42, {:reasoning_delta, "Report the failure."}},
|
|
293
|
+ |
socket
|
|
294
|
+ |
)
|
|
295
|
+ |
|
|
296
|
+ |
assert [first_reasoning, first_tool, second_reasoning, second_tool, final_reasoning] =
|
|
297
|
+ |
socket.assigns.assistant_blocks
|
|
298
|
+ |
|
|
299
|
+ |
assert first_reasoning.type == :reasoning
|
|
300
|
+ |
assert first_reasoning.text == "First attempt."
|
|
301
|
+ |
assert is_integer(first_reasoning.duration)
|
|
302
|
+ |
assert first_tool.type == :tool
|
|
303
|
+ |
assert first_tool.tool_call.state == "output-error"
|
|
304
|
+ |
assert first_tool.tool_call.error == "Not found"
|
|
305
|
+ |
assert second_reasoning.type == :reasoning
|
|
306
|
+ |
assert second_reasoning.text == "Second attempt."
|
|
307
|
+ |
assert is_integer(second_reasoning.duration)
|
|
308
|
+ |
assert second_tool.type == :tool
|
|
309
|
+ |
assert second_tool.tool_call.state == "output-error"
|
|
310
|
+ |
assert second_tool.tool_call.error == "Still not found"
|
|
311
|
+ |
assert final_reasoning.type == :reasoning
|
|
312
|
+ |
assert final_reasoning.text == "Report the failure."
|
|
313
|
+ |
assert is_nil(final_reasoning.duration)
|
|
314
|
+ |
end
|
|
315
|
+ |
|
|
316
|
+ |
test "the browser renders durable tool workspace, duration, output, and receipts", %{conn: conn} do
|
|
317
|
+ |
key = "placeholder-tool-metadata"
|
|
318
|
+ |
user = github_user(key)
|
|
319
|
+ |
conn = log_in_admin_user(conn, key)
|
|
320
|
+ |
|
|
321
|
+ |
streamer = fn _request, callback, _options ->
|
|
322
|
+ |
callback.(
|
|
323
|
+ |
{:tool_call_started,
|
|
324
|
+ |
%{
|
|
325
|
+ |
"call_id" => "call-read",
|
|
326
|
+ |
"name" => "read",
|
|
327
|
+ |
"arguments" => ~s({"path":"README.md"})
|
|
328
|
+ |
}}
|
|
329
|
+ |
)
|
|
330
|
+ |
|
|
331
|
+ |
callback.(
|
|
332
|
+ |
{:tool_call_completed,
|
|
333
|
+ |
%{
|
|
334
|
+ |
"call_id" => "call-read",
|
|
335
|
+ |
"output" => %{
|
|
336
|
+ |
"schema" => "sarah.tool_outcome.v1",
|
|
337
|
+ |
"status" => "succeeded",
|
|
338
|
+ |
"result" => %{"content" => "OpenAgents"},
|
|
339
|
+ |
"workspace" => %{
|
|
340
|
+ |
"type" => "forge_worktree",
|
|
341
|
+ |
"path" => "/private/var/lib/openagents/workspaces/repo"
|
|
342
|
+ |
},
|
|
343
|
+ |
"target_receipt_refs" => ["receipt:read:1"],
|
|
344
|
+ |
"started_at" => "2026-08-22T19:43:28.000Z",
|
|
345
|
+ |
"completed_at" => "2026-08-22T19:43:28.025Z"
|
|
346
|
+ |
}
|
|
347
|
+ |
}}
|
|
348
|
+ |
)
|
|
349
|
+ |
|
|
350
|
+ |
{:ok, %{"assistant_content" => "Read the file."}}
|
|
351
|
+ |
end
|
|
352
|
+ |
|
|
353
|
+ |
assert {:ok, %{"id" => run_id}} =
|
|
354
|
+ |
OpenAgents.Chat.AccountTurns.submit(user, "Read the README.",
|
|
355
|
+ |
subscriber: self(),
|
|
356
|
+ |
streamer: streamer
|
|
357
|
+ |
)
|
|
358
|
+ |
|
|
359
|
+ |
assert_receive {:account_chat_completed, ^run_id, {:ok, _completion}}
|
|
360
|
+ |
{:ok, view, _html} = live(conn, ~p"/chat")
|
|
361
|
+ |
|
|
362
|
+ |
block_id = "chat-console-block-#{run_id}-0"
|
|
363
|
+ |
assert has_element?(view, "##{block_id}-metadata", "succeeded")
|
|
364
|
+ |
assert has_element?(view, "##{block_id}-metadata", "repo")
|
|
365
|
+ |
refute render(view) =~ "/private/var/lib/openagents"
|
|
366
|
+ |
assert has_element?(view, "##{block_id}-metadata", "25 ms")
|
|
367
|
+ |
assert has_element?(view, "##{block_id}-output", "OpenAgents")
|
|
368
|
+ |
assert has_element?(view, "##{block_id}-receipts", "receipt:read:1")
|
|
369
|
+ |
end
|
|
370
|
+ |
|
|
371
|
+ |
test "streaming typed tool failures retain status and error code" do
|
|
372
|
+ |
socket =
|
|
373
|
+ |
%Phoenix.LiveView.Socket{}
|
|
374
|
+ |
|> Phoenix.Component.assign(:stream_id, 84)
|
|
375
|
+ |
|> Phoenix.Component.assign(:streaming?, true)
|
|
376
|
+ |
|> Phoenix.Component.assign(:assistant_tool_calls, [])
|
|
377
|
+ |
|> Phoenix.Component.assign(:assistant_blocks, [])
|
|
378
|
+ |
|
|
379
|
+ |
{:noreply, socket} =
|
|
380
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
381
|
+ |
{:openrouter_stream_event, 84,
|
|
382
|
+ |
{:tool_call_started, %{"call_id" => "call-edit", "name" => "edit", "arguments" => "{}"}}},
|
|
383
|
+ |
socket
|
|
384
|
+ |
)
|
|
385
|
+ |
|
|
386
|
+ |
{:noreply, socket} =
|
|
387
|
+ |
OpenAgentsWeb.ChatConsoleLive.handle_info(
|
|
388
|
+ |
{:openrouter_stream_event, 84,
|
|
389
|
+ |
{:tool_call_failed,
|
|
390
|
+ |
%{
|
|
391
|
+ |
"call_id" => "call-edit",
|
|
392
|
+ |
"output" => %{
|
|
393
|
+ |
"schema" => "sarah.tool_outcome.v1",
|
|
394
|
+ |
"status" => "failed",
|
|
395
|
+ |
"error" => %{
|
|
396
|
+ |
"code" => "workspace_read_only",
|
|
397
|
+ |
"message" => "The workspace is read-only."
|
|
398
|
+ |
},
|
|
399
|
+ |
"workspace" => %{"path" => "/private/var/lib/openagents/workspaces/repo"}
|
|
400
|
+ |
}
|
|
401
|
+ |
}}},
|
|
402
|
+ |
socket
|
|
403
|
+ |
)
|
|
404
|
+ |
|
|
405
|
+ |
assert [%{tool_call: tool}] = socket.assigns.assistant_blocks
|
|
406
|
+ |
assert tool.status == "failed"
|
|
407
|
+ |
assert tool.state == "output-error"
|
|
408
|
+ |
assert tool.error_code == "workspace_read_only"
|
|
409
|
+ |
assert tool.error == "The workspace is read-only."
|
|
410
|
+ |
assert tool.workspace_label == "repo"
|
|
411
|
+ |
end
|
|
412
|
+ |
end
|