Skip to content

stopAtToolNames does not return finalOutput #247

@mhashas

Description

@mhashas
export const createGetActionLogsAgent = (
  model: Model,
  adminApiToolkit: AdminApiToolkit,
) =>
  new Agent({
    name: 'get_action_logs',
    instructions: buildInstruction(),
    model: model,
    tools: [
      createGetActionLogsFiltersTool(),
      createQueryActionLogsTool(adminApiToolkit),
    ],
    toolUseBehavior: { stopAtToolNames: ['query_action_logs'] },
  });

const actionLogsAgent = createGetActionLogsAgent(model, adminApiToolkit);

const tools = [
  actionLogsAgent.asTool({
    toolName: 'get_action_logs',
    toolDescription: GET_ACTION_LOGS_TOOL_DESCRIPTION,
    // in theory should not be needed, but without it the content is '', might be a bug in the library
    customOutputExtractor: (output: RunResult<any, any>) => {
      return output.finalOutput;
    },
  }),

I would expect to not have to write this customOutputExtractor. queryActionLogs returns a very long string in case it matters.

I also have an extra question, is there an easy way to unit tests the tools?

  describe('createGetActionLogsFiltersTool', () => {
    const tool = createGetActionLogsFiltersTool();
    test('should have correct name and description', () => {
      expect(tool.name).toBe('get_action_logs_filters');
      expect(tool.description).toBe(
        'Generate valid filters for action logs query.',
      );
    });
  });
});

Basically how can I call the tool.execute method. I found a function (forgot the name) but requires passing contexts, etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions