Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion src/api/AgentRuns/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseResource } from "../BaseResource";
import { Configuration } from "../../Configuration";
import { AgentRun, CreateAgentRunRequest } from "../../models/AgentRun";
import { AgentRun, CreateAgentRunRequest, UpdateAgentRunRequest } from "../../models/AgentRun";
import { Activities } from "./Activities";

/**
Expand Down Expand Up @@ -34,5 +34,16 @@ export class AgentRuns extends BaseResource {
async retrieve(workspaceSlug: string, runId: string): Promise<AgentRun> {
return this.get<AgentRun>(`/workspaces/${workspaceSlug}/runs/${runId}/`);
}

/**
* Update an agent run
* @param workspaceSlug - The workspace slug
* @param runId - The agent run ID
* @param data - The fields to update
* @returns The updated agent run
*/
async update(workspaceSlug: string, runId: string, data: UpdateAgentRunRequest): Promise<AgentRun> {
return this.patch<AgentRun>(`/workspaces/${workspaceSlug}/runs/${runId}/`, data);
}
}

17 changes: 17 additions & 0 deletions src/models/AgentRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export interface CreateAgentRunRequest {
type?: AgentRunType;
}

/**
* Update agent run request interface
*/
export interface UpdateAgentRunRequest {
external_link?: string | null;
}

/**
* Agent run activity content for action type
*/
Expand All @@ -84,6 +91,14 @@ export interface AgentRunActivityTextContent {
*/
export type AgentRunActivityContent = AgentRunActivityActionContent | AgentRunActivityTextContent;

/**
* Top-level action attached to an activity (e.g. a CTA button shown below the response body).
*/
export interface AgentRunActivityAction {
name: string;
redirect_url: string | null;
}

/**
* Agent Run Activity interface
*/
Expand All @@ -99,6 +114,7 @@ export interface AgentRunActivity extends BaseModel {
type: AgentRunActivityType;
project?: string;
workspace: string;
actions?: AgentRunActivityAction[];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Use singular nullable action here to match the intended API contract.

Line 117 and Line 130 currently expose actions?: AgentRunActivityAction[], but the feature goal is a single top-level CTA (action?: AgentRunActivityAction | null). With the current shape, callers passing action still won’t type-check as intended.

Proposed fix
 export interface AgentRunActivity extends BaseModel {
@@
-  actions?: AgentRunActivityAction[];
+  action?: AgentRunActivityAction | null;
 }
@@
 export interface CreateAgentRunActivityRequest {
@@
-  actions?: AgentRunActivityAction[];
+  action?: AgentRunActivityAction | null;
 }

Also applies to: 130-130

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models/AgentRun.ts` at line 117, Change the top-level property from an
array to a nullable singular field: replace occurrences of actions?:
AgentRunActivityAction[] with action?: AgentRunActivityAction | null in the
AgentRun model so the type matches the API contract; update the declarations
referenced (the property at/around the AgentRun interface/class and the other
occurrence currently named actions) to use the singular name "action" and allow
nullability instead of an array so callers passing a single action will
type-check correctly.

}

/**
Expand All @@ -111,4 +127,5 @@ export interface CreateAgentRunActivityRequest {
signal_metadata?: Record<string, any>;
type: Exclude<AgentRunActivityType, "prompt">;
project?: string;
actions?: AgentRunActivityAction[];
}
Loading