refactor(agent-sdk): drop Run.conversation() and update terminal states

There is no per-run conversation endpoint on the backend; conversation
history is session-scoped. Callers should use SessionHandle.conversation()
instead. Also update TERMINAL_STATES to the new RunStatus values
(finished/cancelled/error).
This commit is contained in:
Ishaan Jaffer 2026-05-06 16:10:28 -07:00
parent 3ffaad8b1a
commit b65d494c39
No known key found for this signature in database

View file

@ -8,14 +8,13 @@ import { requestJson, type ResolvedClient } from "./client/http.js";
import { streamRunEvents } from "./client/sse.js";
import {
LiteLLMAgentError,
type ConversationTurn,
type RunEvent,
type RunInfo,
type RunResult,
type RunStatus,
} from "./types.js";
const TERMINAL_STATES: RunStatus[] = ["completed", "failed", "cancelled"];
const TERMINAL_STATES: RunStatus[] = ["finished", "cancelled", "error"];
const DEFAULT_WAIT_POLL_MS = 500;
export class Run {
@ -102,17 +101,9 @@ export class Run {
};
}
/** Snapshot of the conversation up through this run. */
async conversation(): Promise<ConversationTurn[]> {
const data = await requestJson<{ turns: ConversationTurn[] }>(
this._client,
{
method: "GET",
path: `/v2/sessions/${encodeURIComponent(this.sessionId)}/runs/${encodeURIComponent(this.id)}/conversation`,
},
);
return data.turns ?? [];
}
// NOTE: There is no per-run conversation endpoint on the backend. The
// conversation is session-scoped — call `session.conversation()` (on the
// owning `SessionHandle`) for the full turn history.
/** Cancel a running run; no-op if already terminal. */
async cancel(): Promise<void> {