Skip to content

Commit 6ff0a71

Browse files
bobbai00claude
andcommitted
refactor(agent-service): type ReActStep tool/message fields precisely
ReActStep used `unknown` for fields whose shapes we actually know: - inputMessages -> ModelMessage[] (the prepared AI SDK messages) - toolCalls[].input -> Record<string, unknown> (tool args are JSON objects) - toolResults[].output -> string (every tool returns via createToolResult/createErrorResult) The AI SDK types tc.input / tr.output as `unknown` for dynamically registered tools, so narrow at the single construction boundary in texera-agent.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1882916 commit 6ff0a71

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

agent-service/src/agent/texera-agent.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,18 @@ export class TexeraAgent {
571571
onStepFinish: async ({ text, toolCalls, toolResults, usage }) => {
572572
stepIndex++;
573573

574+
// The AI SDK types tc.input / tr.output as `unknown` for dynamically
575+
// registered tools; narrow to the shapes our tools actually produce
576+
// (object args, string results — see tools/*).
574577
const formattedToolCalls = toolCalls?.map(tc => ({
575578
toolName: tc.toolName,
576579
toolCallId: tc.toolCallId,
577-
input: tc.input,
580+
input: tc.input as Record<string, unknown>,
578581
}));
579582

580583
const formattedToolResults = toolResults?.map(tr => ({
581584
toolCallId: tr.toolCallId,
582-
output: tr.output,
585+
output: tr.output as string,
583586
isError: !!(tr.output as any)?.error,
584587
}));
585588

agent-service/src/types/agent.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* under the License.
1818
*/
1919

20+
import type { ModelMessage } from "ai";
2021
import type { WorkflowContent } from "./workflow";
2122

2223
export enum AgentState {
@@ -48,15 +49,15 @@ export interface ReActStep {
4849
toolCalls?: Array<{
4950
toolName: string;
5051
toolCallId: string;
51-
input: unknown;
52+
input: Record<string, unknown>;
5253
}>;
5354
toolResults?: Array<{
5455
toolCallId: string;
55-
output: unknown;
56+
output: string;
5657
isError?: boolean;
5758
}>;
5859
usage?: TokenUsage;
59-
inputMessages?: unknown[];
60+
inputMessages?: ModelMessage[];
6061
messageSource?: "chat" | "feedback";
6162
beforeWorkflowContent?: WorkflowContent;
6263
afterWorkflowContent?: WorkflowContent;

0 commit comments

Comments
 (0)