Commit Graph

362 Commits

Author SHA1 Message Date
Jordan Ritter 6c4162c2d0 fix: support per-request agent factory function (#2941)
Add AgentsFactory type that accepts a function receiving request context,
enabling multi-tenant and request-scoped agent configuration. The agents
option now accepts a static record, a Promise, or a factory function.
2026-04-12 16:09:41 -07:00
Jordan Ritter 2cf4021eaa fix: skip content_block_delta events for unknown tool_use blocks
When mode is null (unknown tool skipped), content_block_delta events
with input_json_delta would still call sendActionExecutionArgs using
the previous valid tool call ID, corrupting its arguments.
2026-04-12 15:31:50 -07:00
Jordan Ritter 39a9eb81ca fix: preserve jsonSchema structure in MCP tool parameter extraction (#1936)
extractParametersFromSchema now preserves enum values as structured
data on string parameters, recursively extracts nested object
attributes, and converts object arrays to object[] type with
attributes. This ensures complex MCP tool schemas survive the
Parameter[] -> Zod conversion without losing nested structure.
2026-04-12 15:17:02 -07:00
Jordan Ritter 0099c1d3e2 fix: honor Retry-After header on 429 responses (#3637)
Parse Retry-After as seconds or HTTP-date and use it as the retry delay
instead of exponential backoff. Throw if the server requests a wait
longer than maxRetryAfterSeconds (60s default) to avoid hanging.
2026-04-12 15:16:35 -07:00
Jordan Ritter 3aadfb34f4 fix: prevent "Unknown provider" regression for LangChainAdapter (#3217)
When getLanguageModel() returns null and provider/model are undefined
(as with LangChainAdapter), the code constructed "undefined/undefined"
as a model string, causing a cryptic "Unknown provider" error.

Now checks each source of model info explicitly and throws a clear
error message directing users to provide an explicit agents config
when using adapters that don't expose model metadata.
2026-04-12 15:16:34 -07:00
Jordan Ritter 18b0d7a831 fix: normalize array content in TOOL_CALL_RESULT for MCP adapters (#2922)
langchain-mcp-adapters sends tool call result content as an array of
{type:"text", text:string} objects. Extract and join text parts so
downstream consumers always receive a plain string.
2026-04-12 15:09:33 -07:00
Jordan Ritter 6b360916b9 fix: always generate unique message IDs in LangChain adapter (#2929)
GoogleGenerativeAI returns "0" as lc_kwargs.id for every message,
which is truthy and bypassed the randomId() fallback. All streamed
messages then shared the same ID, breaking message deduplication.
Now we always use randomId() for new message streams.
2026-04-12 15:05:20 -07:00
Jordan Ritter 7e02057885 fix: skip unknown tool_use blocks in Anthropic adapter to prevent crashes (#2504) 2026-04-12 15:02:45 -07:00
Jordan Ritter 3528a1f200 fix: ensure TextMessageOutput.id is never null by falling back to randomId() (#2118) 2026-04-12 14:59:03 -07:00
Jordan Ritter 8cd2facb7d fix: pass hookParams to onAfterRequest instead of empty object (#2124)
The onAfterRequest middleware callback was being called with an empty
object `{}` instead of the available hook parameters (threadId, runId,
messages, path). Extract and forward these from the hookParams that the
v2 runtime provides.
2026-04-12 13:33:31 -07:00
Jordan Ritter e121937a6d fix: replace non-unique provider IDs like txt-0 with UUIDs (#3410, #3623)
Providers like @ai-sdk/openai-compatible emit sequential IDs (txt-0,
reasoning-0, msg-0) that collide across requests. The existing check
only caught the literal "0". Expand the check to match the
^(txt|reasoning|msg)-0$ pattern and always use randomUUID() for these.
2026-04-12 13:33:05 -07:00
Jordan Ritter a82c1f09cc fix: use duck-type check for Request instead of instanceof (#2986)
When @hono/node-server polyfills the Request class, instanceof fails
because the polyfilled object has a different prototype chain.

Replace `reqOrRequest instanceof Request` with a duck-type check
that verifies url, method, and headers properties exist, which
works with both native and polyfilled Request objects.
2026-04-12 13:22:58 -07:00
Jordan Ritter 641da3350e fix: increase Anthropic adapter default max_tokens from 1024 to 4096 (#2354)
The hardcoded 1024 default was too restrictive for most use cases,
causing truncated responses. Increase to 4096 as a more reasonable
default while still respecting user-provided maxTokens.
2026-04-12 13:21:00 -07:00
tylerslaton ccdd276a6d chore: release monorepo v1.55.3 2026-04-11 06:24:17 +00:00
github-actions[bot] 087cbae689 chore: version packages 2026-04-10 23:38:59 +00:00
github-actions[bot] 4fcfe35fc5 style: auto-fix formatting 2026-04-10 14:02:10 -05:00
Max Korp 215bfd9385 test(runtime): add thread route coverage to fetch-router tests 2026-04-10 14:02:10 -05:00
Max Korp 395e10059c fix(runtime): restore thread routes dropped during fetch-handler rewrite 2026-04-10 14:02:10 -05:00
github-actions[bot] 3e43f35131 chore: version packages (next) 2026-04-10 18:29:58 +00:00
Alem Tuzlak ff2093102c chore(lint): add new oxlint rules and auto-fix violations
Enable stricter oxlint rules for better code health:
- typescript/consistent-type-imports: enforce `import type` for type-only imports
- typescript/no-import-type-side-effects: prefer top-level type imports
- import/consistent-type-specifier-style: consistent type specifier placement
- typescript/no-unnecessary-type-assertion: bump to error
- react/self-closing-comp: enforce self-closing JSX components
- unicorn/prefer-optional-catch-binding: drop unused catch params
- eslint/no-useless-computed-key: simplify object keys
- unicorn/prefer-string-slice: prefer .slice() over .substring()
- unicorn/prefer-array-flat-map: prefer .flatMap() over .map().flat()

All existing violations auto-fixed via oxlint --fix.
2026-04-10 19:29:32 +02:00
Martha Kelly Schumann fd1b060cad Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-10 09:07:25 -07:00
Alem Tuzlak c3fc0091a0 fix(runtime): widen TanStack message content type for adapter compat
TanStackChatMessage.content uses any[] for multimodal so
messages are directly passable to any adapter without casts.
Add env.d.ts with vite/client types for CSS imports.
2026-04-10 17:53:43 +02:00
Alem Tuzlak 672d3cf2e1 fix(runtime): preserve empty text parts in TanStack converter
Fix falsy check dropping valid empty-string text parts.
Add tests for unknown part types, null content, and
binary parts with neither data nor url.
2026-04-10 17:29:24 +02:00
Alem Tuzlak 4a69d7a8e3 feat(runtime): add multimodal support to TanStack converter
- Fix convertInputToTanStackAI silently dropping multimodal
  content (images, audio, video, documents) by converting
  AG-UI content parts to TanStack AI ContentPart format
- Switch react-router example from Hono server to a React
  Router resource route using createCopilotRuntimeHandler
- Both agents now use BuiltInAgent factory pattern
- Remove hono/react-router-hono-server deps from example
2026-04-10 17:15:57 +02:00
Tyler Slaton 214924c7f9 Merge branch 'main' into worktree-fancy-mapping-valley 2026-04-09 20:47:51 -07:00
Martha Kelly Schumann 334d823207 Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-09 18:41:05 -07:00
Jordan Ritter 1b01725d40 test: add 18 MCP integration tests with aimock MCPMock
Phase 1 — BasicAgent mcpServers (8 tests):
- HTTP transport tool fetch, SSE error handling
- Tool call round-trip, client cleanup, unreachable server error
- Multiple servers merge tools, error-path cleanup, tool descriptions

Phase 2 — MCPAppsActivityRenderer proxy (5 tests):
- tools/call proxy round-trip, error handling
- ui/open-link handler + missing URL error
- Multiple independent activities

Phase 3 — MCPAppsMiddleware edge cases (5 tests):
- Middleware creation, tools/call proxy, resources/read proxy
- Non-proxied request delegation, wrong serverHash error

All tests use real HTTP connections to aimock MCPMock.
2026-04-09 14:58:32 -07:00
Jordan Ritter 55663ee69f chore(runtime): add @copilotkit/aimock devDependency for MCP integration tests 2026-04-09 14:54:07 -07:00
Alem Tuzlak 3dd17c1c5b Merge branch 'main' into worktree-fancy-mapping-valley 2026-04-09 20:40:27 +02:00
Martha Kelly Schumann 3f314a5776 Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-09 11:28:55 -07:00
Martha Kelly Schumann ac0f33884c Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-09 11:14:47 -07:00
github-actions[bot] 1bc4786759 chore: version packages (next) 2026-04-09 18:09:30 +00:00
Tyler Slaton 62c604213c chore(a2ui-renderer): bump version for a2ui-middleware to 0.0.4
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-04-09 11:05:10 -07:00
Martha Kelly Schumann 1a4ed9d639 Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-09 07:27:59 -07:00
github-actions[bot] 0093bdbaa4 chore: version packages 2026-04-09 02:26:42 +00:00
github-actions[bot] c2837a3001 chore: version packages (next) 2026-04-09 01:53:20 +00:00
Tyler Slaton 422f5f55e1 fix(open-gen-ui): correctly import clairinet
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-04-08 18:09:03 -07:00
github-actions[bot] 00cace6abf chore: version packages 2026-04-08 23:54:54 +00:00
Ben Taylor ca233aea20 Revert "fix: catch async errors in LangGraphAgent.run() Observable" 2026-04-08 18:40:52 -05:00
Max Korp c5d712f4cf test(runtime): add unit tests for LangGraphAgent.run() async error handling
Verify that async rejections from runAgentStream are routed through the
Observable error channel instead of becoming unhandled promise rejections.
2026-04-08 16:17:55 -07:00
Max Korp cffc4cafe0 fix: catch async errors in LangGraphAgent.run() Observable
The base class @ag-ui/langgraph creates an Observable that calls
runAgentStream() but ignores the returned Promise. Any async rejection
becomes an unhandled promise rejection that crashes the process.

Override run() to properly route async errors through the Observable
error channel so downstream catchError handlers can process them.
2026-04-08 16:17:55 -07:00
Max Korp 2142ecea99 fix: use plain UUID for thread-naming runs 2026-04-08 13:52:06 -07:00
Markus Ecker e6988014f8 feat(runtime): OpenGenerativeUI middleware + A2UI config cleanup
Add OpenGenerativeUIMiddleware (clarinet streaming JSON parser, held event
buffering, activity snapshot/delta conversion), remove a2ui boolean shorthand,
includeBasicCatalog defaults to false, before_agent SystemMessage ID reuse fix.
2026-04-08 12:50:18 -07:00
Alem Tuzlak 990acb46ab fix(runtime): address CR round 1 findings
- Fix all doc imports to use @copilotkit/runtime/v2 (symbols only
  exported from v2 entry point)
- Replace v1 copilotRuntimeNextJSAppRouterEndpoint with v2 pattern
  (CopilotRuntime + createCopilotEndpoint + InMemoryAgentRunner)
- Add warning callout on TanStack reasoning example (reasoning events
  not surfaced by TanStack converter)
- Fix randomUUID imports in converters: use @copilotkit/shared instead
  of Node.js crypto to match codebase convention
- Fix collectEvents timer leak in test-helpers.ts (add clearTimeout)
- Fix JSDoc/comments: convertInputToTanStackAI accurately describes
  role allowlist, TanStackInputResult.messages comment updated
2026-04-08 18:03:44 +02:00
Martha Kelly Schumann 04d73d1dca Merge branch 'main' into claude/langgraph-tests-cleanup-1jVZ3 2026-04-08 08:52:43 -07:00
Alem Tuzlak a8715b9631 style(runtime): fix formatting in agent test files 2026-04-08 17:40:47 +02:00
Alem Tuzlak 9b15a7c378 fix(runtime): address PR review feedback
- Close TOCTOU window: set abortController synchronously before Observable
  creation in classic run(), matching factory run() pattern (M3)
- Add concurrent run guard to classic run() (C1)
- Add threadId/runId to RUN_ERROR events in classic mode (I2)
- Check both 'output' and 'result' property names in classic tool-result (C2/M2)
- Add try/catch around JSON.stringify in classic tool-result (I4/M2)
- Add undefined guards before emitting state snapshot/delta events (I3)
- Guard assignToolsToAgents against factory-mode agent configs (M1)
- Improve error handling in classic error case with proper fallback (C3)
- Improve TanStack converter TODO comment with known gap details (M5)
- Document @ts-expect-error on clone() middlewares access (S1)
- Add JSDoc to AgentFactoryContext.abortController (M4)
- Fix duplicate import and clean up react-router example
- Update docs AgentFactoryContext reference
2026-04-08 17:32:50 +02:00
Alem Tuzlak 920640cb5a test(runtime): update Agent tests to use BuiltInAgent factory mode 2026-04-08 17:15:00 +02:00
Alem Tuzlak 802d20e95d refactor(runtime): remove Agent class, absorb into BuiltInAgent 2026-04-08 17:14:59 +02:00
Alem Tuzlak 3fcf2fbaf9 feat(runtime): add factory-path branch to BuiltInAgent.run()
- Add converter imports (convertAISDKStream, convertTanStackStream) to agent/index.ts
- Update canOverride() to return false for factory configs
- Add factory-path early return in run() that delegates to runFactory()
- Add private runFactory() method that handles aisdk/tanstack/custom factory configs
  with full lifecycle management (RUN_STARTED, RUN_FINISHED, RUN_ERROR, abort support)
- Fix copilot-runtime.ts: change BuiltInAgentConfiguration["tools"] indexed access
  types to BuiltInAgentClassicConfig["tools"] since tools only exist on classic configs
2026-04-08 17:14:58 +02:00