agent: remove unused code and add recorder guard

This commit is contained in:
Adrià Arrufat
2026-05-07 10:34:14 +02:00
parent 25f8dfcab3
commit 02ae92d619
3 changed files with 19 additions and 26 deletions

View File

@@ -28,11 +28,6 @@ pub const SchemaInfo = struct {
hints: []const HintSlot,
};
pub const Parsed = struct {
schema: *const SchemaInfo,
args_json: []const u8,
};
pub const ParseError = error{
MissingName,
UnknownTool,
@@ -152,14 +147,6 @@ pub fn splitNameRest(input: []const u8) ?Split {
};
}
/// Parse a slash command body (without the leading `/`).
/// `arena` is used for the resulting JSON string and any temporary storage.
pub fn parse(arena: std.mem.Allocator, schemas: []const SchemaInfo, input: []const u8) ParseError!Parsed {
const split = splitNameRest(input) orelse return error.MissingName;
const schema = findSchema(schemas, split.name) orelse return error.UnknownTool;
return .{ .schema = schema, .args_json = try parseArgs(arena, schema, split.rest) };
}
/// Parse the args portion of a slash command for an already-resolved schema.
pub fn parseArgs(arena: std.mem.Allocator, schema: *const SchemaInfo, rest: []const u8) ParseError![]const u8 {
if (rest.len == 0) {
@@ -315,7 +302,12 @@ fn lookupFieldType(schema: *const SchemaInfo, key: []const u8) FieldType {
const testing = std.testing;
fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !Parsed {
const ParsedTest = struct {
schema: *const SchemaInfo,
args_json: []const u8,
};
fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !ParsedTest {
const tools = try arena.alloc(zenai.provider.Tool, browser_tools.tool_defs.len);
for (browser_tools.tool_defs, 0..) |td, i| {
tools[i] = .{
@@ -325,7 +317,9 @@ fn parseWithCache(arena: std.mem.Allocator, input: []const u8) !Parsed {
};
}
const schemas = try buildSchemas(arena, tools);
return parse(arena, schemas, input);
const split = splitNameRest(input) orelse return error.MissingName;
const schema = findSchema(schemas, split.name) orelse return error.UnknownTool;
return .{ .schema = schema, .args_json = try parseArgs(arena, schema, split.rest) };
}
fn expectParse(input: []const u8, expected_tool: []const u8, expected_json: []const u8) !void {