server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
last := subagentTestLastItem(call)
switch {
server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
last := subagentTestLastItem(call)
switch {
name := test.events.Last("subagent")
require.True(t, subagentNameValid(name), name)
name := test.events.Last("subagent")
require.True(t, subagentNameValid(name), name)
work := filepath.Join(test.loop.runs.subagents.dir, name, "work")
require.DirExists(t, work)
work := filepath.Join(test.loop.runs.subagents.dir, name, "work")
require.DirExists(t, work)
require.Equal(t, "subagent "+name+" started\nsubagent "+name+" done after 0s\n", test.logs.String())
var first, second *ModelFakeCall
require.Equal(t, "subagent "+name+" started\nsubagent "+name+" done after 0s\n", test.logs.String())
var first, second *ModelFakeCall
for _, tool := range first.body["tools"].([]any) {
tools = append(tools, tool.(map[string]any)["name"].(string))
}
for _, tool := range first.body["tools"].([]any) {
tools = append(tools, tool.(map[string]any)["name"].(string))
}
require.Equal(t, "0|note: subagent\n\n1|user: Count the files.\n\n2|tool: shell {\"command\":\"pwd\"}\n\n3|echo: "+work+"\n\n\n4|reply: There are 3 files.", log)
var agents []string
require.Equal(t, "0|note: subagent\n\n1|user: Count the files.\n\n2|tool: shell {\"command\":\"pwd\"}\n\n3|echo: "+work+"\n\n\n4|reply: There are 3 files.", log)
var agents []string
for _, record := range modelReadUsage(t, test.usagePath) {
agents = append(agents, record.Agent)
}
for _, record := range modelReadUsage(t, test.usagePath) {
agents = append(agents, record.Agent)
}
report := subagentReport("GreenOtter", []string{"It is done."})
test.loop.Report("GreenOtter", report, subagentFinished)
close(release)
report := subagentReport("GreenOtter", []string{"It is done."})
test.loop.Report("GreenOtter", report, subagentFinished)
close(release)
server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
if subagentTestCall(call) {
w.WriteHeader(http.StatusBadRequest)
server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
if subagentTestCall(call) {
w.WriteHeader(http.StatusBadRequest)
name := test.events.Last("subagent")
output, err := runs.Tell(t.Context(), name, "Use the second disk.")
require.NoError(t, err)
name := test.events.Last("subagent")
output, err := runs.Tell(t.Context(), name, "Use the second disk.")
require.NoError(t, err)
name := test.events.Last("subagent")
_, err = runs.Tell(t.Context(), name, "Count again.")
require.NoError(t, err)
name := test.events.Last("subagent")
_, err = runs.Tell(t.Context(), name, "Count again.")
require.NoError(t, err)
server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
switch {
case subagentTestCall(call) && !restarted.Load():
arrived <- struct{}{}
server.reply = func(w http.ResponseWriter, call ModelFakeCall) {
switch {
case subagentTestCall(call) && !restarted.Load():
arrived <- struct{}{}
<-release
case subagentTestCall(call):
modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Built.")}, 100, 0, 5))
<-release
case subagentTestCall(call):
modelWriteEvents(w, modelCompletedEvent([]any{modelMessageItem("Built.")}, 100, 0, 5))
second := &TurnEventRecorder{}
loop, memory, stop := subagentTestStart(t, agent, server, second)
defer stop()
second.WaitFor(t, "idle", 1)
second := &TurnEventRecorder{}
loop, memory, stop := subagentTestStart(t, agent, server, second)
defer stop()
second.WaitFor(t, "idle", 1)
note := "The daemon restarted, cutting " + name + "; nothing was lost: go on."
log := subagentTestChat(t, memory)
require.Equal(t, []string{
note := "The daemon restarted, cutting " + name + "; nothing was lost: go on."
log := subagentTestChat(t, memory)
require.Equal(t, []string{
for id := range memory.Len() {
message, err := memory.Message(id)
require.NoError(t, err)
for id := range memory.Len() {
message, err := memory.Message(id)
require.NoError(t, err)
// another item.
func subagentTestText(item map[string]any) string {
content, _ := item["content"].([]any)
// another item.
func subagentTestText(item map[string]any) string {
content, _ := item["content"].([]any)
for _, part := range content {
value, _ := part.(map[string]any)["text"].(string)
text.WriteString(value)
for _, part := range content {
value, _ := part.(map[string]any)["text"].(string)
text.WriteString(value)