InjectClaudeNonStream appends a tool_use content block to a real Claude message response and sets stop_reason to "tool_use".
(resp []byte, rule *config.ToolCallInjectionRule)
| 43 | // InjectClaudeNonStream appends a tool_use content block to a real Claude message response |
| 44 | // and sets stop_reason to "tool_use". |
| 45 | func InjectClaudeNonStream(resp []byte, rule *config.ToolCallInjectionRule) []byte { |
| 46 | toolUseID := GenerateClaudeToolUseID(rule.TaskID) |
| 47 | |
| 48 | block := map[string]any{ |
| 49 | "type": "tool_use", |
| 50 | "id": toolUseID, |
| 51 | "name": rule.ToolName, |
| 52 | "input": rule.Arguments, |
| 53 | } |
| 54 | |
| 55 | resp, _ = sjson.SetBytes(resp, "content.-1", block) |
| 56 | resp, _ = sjson.SetBytes(resp, "stop_reason", "tool_use") |
| 57 | return resp |
| 58 | } |
| 59 | |
| 60 | // InjectResponsesNonStream appends a function_call item to a real OpenAI Responses API response. |
| 61 | func InjectResponsesNonStream(resp []byte, rule *config.ToolCallInjectionRule) []byte { |
no test coverage detected