Commit graph

37 commits

Author SHA1 Message Date
Ishaan Jaffer
1b0ca087d4
test(agent-sdk): cover snake_case <-> camelCase transform helpers
Round-trip + edge-case coverage: digits in keys (agent_v2_id), nested
objects, arrays of objects, top-level arrays, single-word key passthrough,
and primitive passthrough.
2026-05-06 16:10:50 -07:00
Ishaan Jaffer
fb05cf0200
test(agent-sdk): switch removed Run.conversation() test to session.conversation()
Also update the wait() test to expect the new 'finished' terminal status.
2026-05-06 16:10:44 -07:00
Ishaan Jaffer
290808fa64
test(agent-sdk): expect 'finished' instead of 'completed' for terminal RunStatus 2026-05-06 16:10:39 -07:00
Ishaan Jaffer
f68bd10230
test(agent-sdk): mirror backend snake_case wire format and new status enums in mock proxy
Mock proxy now serializes responses using snake_case keys (agent_id,
created_at, system_prompt, run_id, etc.) and reads request bodies as
snake_case so it matches the real backend that the SDK now talks to via
the new transform layer. Also update the status string literals to the
new SessionStatus and RunStatus values, and read the followup body as
{prompt: {text}}.
2026-05-06 16:10:35 -07:00
Ishaan Jaffer
b65d494c39
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).
2026-05-06 16:10:28 -07:00
Ishaan Jaffer
3ffaad8b1a
fix(agent-sdk): send {prompt: {text}} as followup body to match backend FollowupCreate
The backend's followup endpoint expects a FollowupCreate payload with a
nested prompt object ({prompt: {text: ...}}), not a flat {message: ...}.
Public method signature followup(message: string) is unchanged - only
the wire body changes.
2026-05-06 16:10:22 -07:00
Ishaan Jaffer
68e58bf69b
feat(agent-sdk): add snake_case <-> camelCase transform layer to HTTP client
Backend speaks snake_case (Python idiom) while the SDK's public TS API
is camelCase. Add recursive snakeToCamel and camelToSnake helpers and
wire them into the HTTP layer so request bodies are camel->snake before
JSON.stringify and response JSON is snake->camel before being returned
to callers. Single-word keys like id/type/data/seq/status pass through
unchanged in both directions, and non-object values are not touched.
2026-05-06 16:10:16 -07:00
Ishaan Jaffer
595f660899
fix(agent-sdk): align SessionStatus and RunStatus enums with backend wire values
Backend (LIT-2890) emits provisioning/ready/busy/error/terminated for
session status and queued/running/finished/cancelled/error for run status.
Update the SDK type aliases so callers compare against the actual values
the proxy returns over the wire.
2026-05-06 16:10:10 -07:00
Ishaan Jaff
6f3895b07c
fix(agent-sdk): cap honored Retry-After at 60s
Greptile P2: a misbehaving or adversarial server returning
'Retry-After: 9999999' could stall the SDK indefinitely. Cap the
honored delay at MAX_RETRY_AFTER_MS (60s).
2026-05-06 15:28:48 -07:00
Ishaan Jaff
642ba64635
fix(agent-sdk): reset SSE reconnect counter after a successful connection
Greptile P1: the reconnects counter accumulated across the entire
stream lifetime — for a long-running stream with several transient
drops over hours, the budget would be exhausted even though every
individual reconnect succeeded. Now the counter tracks *consecutive*
failures: once a connection delivers at least one new event, the
counter resets to zero on the next drop, so only a sustained outage
trips sse_reconnect_exhausted.
2026-05-06 15:28:42 -07:00
Ishaan Jaff
67cad5ea60
fix(agent-sdk): add timeout/abort support to Run.wait() and drop runFromInfo
Greptile P1: wait() polled indefinitely with no escape hatch — a stuck
or partitioned server would hang the caller forever. Now accepts
{ signal, timeoutMs, pollMs } and throws LiteLLMAgentError with codes
wait_aborted / wait_timeout. Forwards the signal to the underlying
requestJson call and to the inter-poll sleep.

Greptile P2: runFromInfo was exported but had no internal callers
(agent.ts and session.ts both build Run directly). Removed to shrink
the surface and avoid leaking resolveClient as a construction detail.
2026-05-06 15:28:35 -07:00
Ishaan Jaffer
db579303fd chore(agent-sdk): ignore package-lock.json (use pnpm) 2026-05-06 15:00:19 -07:00
Ishaan Jaffer
a371832337 test(agent-sdk): add Symbol.asyncDispose teardown test 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
66527b6beb test(agent-sdk): add session.followup queueing test 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
bd1539285a test(agent-sdk): add SSE auto-reconnect test 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
b4b6c109e7 test(agent-sdk): add agent-reuse multi-session test 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
4926177cfd test(agent-sdk): add noop-roundtrip end-to-end test 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
e3683ec956 test(agent-sdk): add Run class tests 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
4aae87bd08 test(agent-sdk): add SessionHandle tests 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
e31d20e93d test(agent-sdk): add Agent class tests 2026-05-06 14:59:56 -07:00
Ishaan Jaffer
93954fc5a0 feat(agent-sdk): add followup multi-turn example 2026-05-06 14:59:48 -07:00
Ishaan Jaffer
61e8a07314 feat(agent-sdk): add basic usage example 2026-05-06 14:59:48 -07:00
Ishaan Jaffer
2f0e1d7415 docs(agent-sdk): add README with quickstart and API reference 2026-05-06 14:59:48 -07:00
Ishaan Jaffer
f68b984fe2 chore(agent-sdk): tweak package.json repository URL 2026-05-06 14:59:43 -07:00
Ishaan Jaffer
1a9fbc63e6 fix: target /v2/ agent-session API 2026-05-06 14:59:21 -07:00
Ishaan Jaffer
49e30b020d
test(agent-sdk): add in-memory mock proxy for tests 2026-05-06 14:52:53 -07:00
Ishaan Jaffer
7ffe2bbdae
feat(agent-sdk): add public surface re-exports 2026-05-06 14:52:53 -07:00
Ishaan Jaffer
82c03fd68a
feat(agent-sdk): add Run class with stream/wait/cancel 2026-05-06 14:52:53 -07:00
Ishaan Jaffer
33eb658f8b
feat(agent-sdk): add SessionHandle with asyncDispose 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
25ffa570c1
feat(agent-sdk): add Agent + AgentHandle classes 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
a7c94022a5
feat(agent-sdk): add SSE client with Last-Event-ID resume 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
8e20ed5ef8
feat(agent-sdk): add fetch wrapper with auth + retry 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
f3965f652a
feat(agent-sdk): add public types and LiteLLMAgentError 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
6fa5f15782
feat(agent-sdk): add vitest config 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
8ffd32036f
feat(agent-sdk): add tsconfig 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
e214328730
feat(agent-sdk): add package.json for @litellm/agent-sdk 2026-05-06 14:52:52 -07:00
Ishaan Jaffer
504c90bad7
feat(agent-sdk): add gitignore for typescript SDK package 2026-05-06 14:52:42 -07:00