Skip to content

Commit 0b78040

Browse files
jcheekAiden
andcommitted
fix: Preserve tool call arguments in tool_result entries
Fixed bug where tool_result entries in context JSON files had empty arguments field. When updating tool_call to tool_result, now explicitly uses chunk.toolCall (with complete arguments from messageReducer) instead of preserving the potentially incomplete original toolCall. Also updated package-lock.json to sync with package.json for CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Aiden <aiden@zds.group>
1 parent a8164a0 commit 0b78040

3 files changed

Lines changed: 54 additions & 53 deletions

File tree

package-lock.json

Lines changed: 43 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/agent/grok-agent.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,12 @@ Current working directory: ${process.cwd()}`;
590590
}
591591
} else if (typeof acc[key] === "string" && typeof value === "string") {
592592
// Don't concatenate certain properties that should remain separate
593-
const nonConcatenableProps = ['id', 'type', 'name', 'arguments'];
593+
const nonConcatenableProps = ['id', 'type', 'name'];
594594
if (nonConcatenableProps.includes(key)) {
595595
// For non-concatenable properties, keep the new value
596596
acc[key] = value;
597597
} else {
598-
// For content and other text properties, concatenate
598+
// For content, arguments, and other text properties, concatenate
599599
(acc[key] as string) += value;
600600
}
601601
} else if (Array.isArray(acc[key]) && Array.isArray(value)) {
@@ -888,6 +888,14 @@ Current working directory: ${process.cwd()}`;
888888

889889
private async executeTool(toolCall: GrokToolCall): Promise<ToolResult> {
890890
try {
891+
// Validate arguments field before parsing
892+
if (!toolCall.function.arguments || toolCall.function.arguments.trim() === "") {
893+
return {
894+
success: false,
895+
error: `Tool ${toolCall.function.name} has empty or missing arguments field`,
896+
};
897+
}
898+
891899
const args = JSON.parse(toolCall.function.arguments);
892900

893901
// Check tool approval hook if configured

src/hooks/use-input-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ Respond with ONLY the commit message, no additional text.`;
813813
return {
814814
...entry,
815815
type: "tool_result",
816+
toolCall: chunk.toolCall, // Use the new toolCall from chunk with complete arguments
816817
content: chunk.toolResult.success
817818
? chunk.toolResult.output || "Success"
818819
: chunk.toolResult.error || "Error occurred",

0 commit comments

Comments
 (0)