Extract the text content of the last step in a trajectory.
Returns an empty string when the trajectory has no steps or the final message has non-string content (e.g. a content-block array).
getFinalText(trajectory: AgentTrajectory): string| Name | Type | Description |
|---|---|---|
trajectory* | AgentTrajectory |
const result = await runAgent(agent, { query: "What is 2+2?" });
expect(getFinalText(result).trim()).toBe("4");