Thanks to visit codestin.com
Credit goes to github.com

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
10 changes: 5 additions & 5 deletions coderd/x/chatd/subagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Guidelines:

type waitAgentArgs struct {
ChatID string `json:"chat_id"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty"`
TimeoutSeconds *int `json:"timeout_seconds,omitempty" description:"Defaults to 5 minutes."`
}

type messageAgentArgs struct {
Expand Down Expand Up @@ -620,10 +620,10 @@ func (p *Server) subagentTools(
),
fantasy.NewAgentTool(
"wait_agent",
"Wait until a spawned child agent finishes its task. "+
"Returns the agent's response and status. A timeout is not "+
"a failure: the agent is still running. Call wait_agent again "+
"or use list_agents to check its status.",
"Wait for a spawned child agent to finish and return its response "+
"and status. Returns immediately when the agent finishes, even if "+
"a longer timeout is set. A timeout does not stop the agent; call "+
"wait_agent again or use list_agents to check its status.",
func(ctx context.Context, args waitAgentArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {
if currentChat == nil {
return fantasy.NewTextErrorResponse("subagent callbacks are not configured"), nil
Expand Down
22 changes: 22 additions & 0 deletions coderd/x/chatd/subagent_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3647,6 +3647,28 @@ func TestAwaitSubagentCompletion(t *testing.T) {
})
}

func TestWaitAgentToolSchema(t *testing.T) {
t.Parallel()

db, ps := dbtestutil.NewDB(t)
server := newInternalTestServer(t, db, ps, chatprovider.ProviderAPIKeys{})
ctx := chatdTestContext(t)
user, org, model := seedInternalChatDeps(t, db)
parent, _ := createParentChildChats(ctx, t, server, user, org, model)

tool := findToolByName(server.subagentTools(ctx, func() database.Chat {
return parent
}, parent.LastModelConfigID), "wait_agent")
require.NotNil(t, tool)

timeoutSeconds, ok := tool.Info().Parameters["timeout_seconds"].(map[string]any)
require.True(t, ok)
assert.Equal(t, "integer", timeoutSeconds["type"])
assert.Equal(t, "Defaults to 5 minutes.", timeoutSeconds["description"])
assert.Contains(t, tool.Info().Description, "Returns immediately when the agent finishes")
assert.Contains(t, tool.Info().Description, "A timeout does not stop the agent")
}

func TestWaitAgentTimeoutReturnsInformationalPayload(t *testing.T) {
t.Parallel()

Expand Down
Loading