Agent: catalog and garden tools, and a ready date on every describe group #130

Merged
steve merged 2 commits from feat/agent-catalog-tools into main 2026-08-23 06:12:26 +00:00
Showing only changes of commit c9076e84c4 - Show all commits
+30 -32
View File
@@ -123,6 +123,34 @@ func TestToolboxScenario(t *testing.T) {
}
}
// toolCaller returns the two ways a test drives a toolbox: call executes a
// tool with JSON-encoded args and hands back the raw result (for asserting on
// refusals), and mustCall fails the test on a tool error and decodes the
// result into `into` when one is given.
func toolCaller(t *testing.T, ctx context.Context, box *llm.Toolbox) (
call func(name string, args any) llm.ToolResult,
mustCall func(name string, args any, into any),
) {
t.Helper()
call = func(name string, args any) llm.ToolResult {
t.Helper()
return box.Execute(ctx, llm.ToolCall{ID: "1", Name: name, Arguments: mustJSON(t, args)})
}
mustCall = func(name string, args any, into any) {
t.Helper()
res := call(name, args)
if res.IsError {
t.Fatalf("%s: %s", name, res.Content)
}
if into != nil {
if err := json.Unmarshal([]byte(res.Content), into); err != nil {
t.Fatalf("decode %s: %v (%s)", name, err, res.Content)
}
}
}
return call, mustCall
}
func mustJSON(t *testing.T, v any) json.RawMessage {
t.Helper()
b, err := json.Marshal(v)
@@ -750,22 +778,7 @@ func TestRecordKeepingTools(t *testing.T) {
svc, owner := newAgentTestService(t)
box := NewToolbox(svc, owner, "2026-08-23")
call := func(name string, args any) llm.ToolResult {
t.Helper()
return box.Execute(ctx, llm.ToolCall{ID: "1", Name: name, Arguments: mustJSON(t, args)})
}
mustCall := func(name string, args any, into any) {
t.Helper()
res := call(name, args)
if res.IsError {
t.Fatalf("%s: %s", name, res.Content)
}
if into != nil {
if err := json.Unmarshal([]byte(res.Content), into); err != nil {
t.Fatalf("decode %s: %v (%s)", name, err, res.Content)
}
}
}
call, mustCall := toolCaller(t, ctx, box)
g, err := svc.CreateGarden(ctx, owner, service.GardenInput{Name: "Home", WidthCM: 1200, HeightCM: 800, Notes: "Zone 6a."})
if err != nil {
3
@@ -940,22 +953,7 @@ func TestCatalogAndGardenTools(t *testing.T) {
svc, owner := newAgentTestService(t)
box := NewToolbox(svc, owner, "2026-08-23")
call := func(name string, args any) llm.ToolResult {
t.Helper()
return box.Execute(ctx, llm.ToolCall{ID: "1", Name: name, Arguments: mustJSON(t, args)})
}
mustCall := func(name string, args any, into any) {
t.Helper()
res := call(name, args)
if res.IsError {
t.Fatalf("%s: %s", name, res.Content)
}
if into != nil {
if err := json.Unmarshal([]byte(res.Content), into); err != nil {
t.Fatalf("decode %s: %v (%s)", name, err, res.Content)
}
}
}
call, mustCall := toolCaller(t, ctx, box)
// --- create_garden: defaults, then an imperial one with notes.
var g domain.Garden