Skip to content

feat: v2 - ai assistant llm proxy and dispatcher agent#2329

Open
maxy-shpfy wants to merge 1 commit into
05-26-feat_v2_-_ai_assistant_web_worker_scaffoldingfrom
05-26-feat_v2_-_ai_assistant_llm_proxy_and_dispatcher_agent
Open

feat: v2 - ai assistant llm proxy and dispatcher agent#2329
maxy-shpfy wants to merge 1 commit into
05-26-feat_v2_-_ai_assistant_web_worker_scaffoldingfrom
05-26-feat_v2_-_ai_assistant_llm_proxy_and_dispatcher_agent

Conversation

@maxy-shpfy
Copy link
Copy Markdown
Collaborator

@maxy-shpfy maxy-shpfy commented May 28, 2026

Description

Wires the @openai/agents SDK into the in-browser AI assistant, replacing the previous echo-only worker stub with a real LLM-backed dispatcher.

A new TangleDispatcher wraps an @openai/agents Agent instance configured to use a user-supplied LLM proxy token stored in IndexedDB via localforage. Static configuration (proxy base URL, model names, proxy mode) is read from a committed src/config/aiAssistantConfig.json file. The proxy token is resolved per-turn from IndexedDB and passed into ensureProxyConfigured(), which rebuilds the OpenAI client only when the token rotates.

The worker's init(onStatus) / ask() lifecycle is preserved. createWorkerApi() now instantiates the dispatcher on init() and delegates ask() calls through it, resolving the token from IndexedDB, creating a per-thread MemorySession, and mapping the result back to the existing AgentResponse shape.

Observability hooks translate @openai/agents lifecycle events (agent_start, agent_end, agent_tool_start, agent_handoff) into human-readable status strings forwarded to the main thread via the Comlink-proxied StatusCallback.

A AiTokenSetup component is shown in the chat panel when no token is stored, allowing the user to paste and save a proxy token without leaving the editor. The token is persisted to IndexedDB and the React Query cache is updated immediately on save.

The Vite worker bundle is configured with a scoped resolveId plugin that forces @openai/agents-core/_shims to resolve to its browser variant, working around Vite's worker bundler not reliably applying the browser export condition. A globalThis.process stub in the worker entry point covers an unguarded process.env read in @openai/agents-core v0.4.x.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Cleanup/Refactor
  • Breaking change
  • Documentation update

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

AI Assistant - Set token and first LLM.mov (uploaded via Graphite)

Test Instructions

  1. Set proxyBaseUrl and orchestratorModel in src/config/aiAssistantConfig.json.
  2. Open the editor and navigate to the AI chat panel.
  3. Paste a valid LLM proxy token into the token setup form and click Save token.
  4. Send a message. Verify the status line updates during the turn (e.g. "Thinking...", "Preparing response...").
  5. Verify the assistant responds with a relevant answer and the thread ID is stable across follow-up messages.
  6. Reload the page and confirm the token is persisted and the setup screen is not shown again.
  7. Clear the token from IndexedDB (e.g. via DevTools) and confirm the setup screen reappears.

Additional Comments

src/config/aiAssistantConfig.json is committed with empty strings for proxyBaseUrl and orchestratorModel. These must be filled in before the assistant will function. The subagentModel field is reserved for a future sub-agent PR and is not read yet.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 28, 2026

🎩 Preview

A preview build has been created at: 05-26-feat_v2_-_ai_assistant_llm_proxy_and_dispatcher_agent/65cce3b

Copy link
Copy Markdown
Collaborator Author

maxy-shpfy commented May 28, 2026

@maxy-shpfy maxy-shpfy force-pushed the 05-26-feat_v2_-_ai_assistant_llm_proxy_and_dispatcher_agent branch from 295b24e to 65cce3b Compare May 28, 2026 05:42
@maxy-shpfy maxy-shpfy force-pushed the 05-26-feat_v2_-_ai_assistant_web_worker_scaffolding branch from 3209a15 to 3a918bd Compare May 28, 2026 05:42
@maxy-shpfy maxy-shpfy marked this pull request as ready for review May 28, 2026 05:59
@maxy-shpfy maxy-shpfy requested a review from a team as a code owner May 28, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant