Conversation
🦋 Changeset detectedLatest commit: 75ac6b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughUpdated dynamic import handling in agent and inference runner process entrypoints to accept both ESM and CJS default-export shapes, resolving nested Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
Files:
**/*.{ts,tsx}?(test|example|spec)📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
Files:
**/*.{ts,tsx}?(test|example)📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
Files:
🧠 Learnings (1)📚 Learning: 2026-01-16T14:33:39.551ZApplied to files:
🔇 Additional comments (1)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@agents/src/ipc/inference_proc_lazy_main.ts`:
- Around line 39-46: The import resolution may yield a non-constructor and
currently leads to a generic "Runner is not a constructor" error; modify the
async import block that builds Runner (the code using awaiting import(v as
string) and the const Runner = typeof m.default === 'function' ? m.default :
m.default?.default) to validate that Runner is a callable constructor before
calling new Runner(); if it's not, throw a descriptive Error that includes the
module identifier (v) and the resolved export shape (e.g., JSON.stringify keys
or typeof m.default) so consumers see which module file and export form was
wrong rather than a vague TypeError.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
agents/src/ipc/inference_proc_lazy_main.tsagents/src/ipc/job_proc_lazy_main.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
Add SPDX-FileCopyrightText and SPDX-License-Identifier headers to all newly added files with '// SPDX-FileCopyrightText: 2025 LiveKit, Inc.' and '// SPDX-License-Identifier: Apache-2.0'
Files:
agents/src/ipc/job_proc_lazy_main.tsagents/src/ipc/inference_proc_lazy_main.ts
**/*.{ts,tsx}?(test|example|spec)
📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
When testing inference LLM, always use full model names from
agents/src/inference/models.ts(e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')
Files:
agents/src/ipc/job_proc_lazy_main.tsagents/src/ipc/inference_proc_lazy_main.ts
**/*.{ts,tsx}?(test|example)
📄 CodeRabbit inference engine (.cursor/rules/agent-core.mdc)
Initialize logger before using any LLM functionality with
initializeLogger({ pretty: true })from '@livekit/agents'
Files:
agents/src/ipc/job_proc_lazy_main.tsagents/src/ipc/inference_proc_lazy_main.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example|spec) : When testing inference LLM, always use full model names from `agents/src/inference/models.ts` (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Use `pnpm build && pnpm dlx tsx ./examples/src/my_agent.ts dev|download-files --log-level=debug|info(default)` to run example agents from the examples directory
Applied to files:
agents/src/ipc/job_proc_lazy_main.ts
📚 Learning: 2026-01-16T14:33:39.551Z
Learnt from: CR
Repo: livekit/agents-js PR: 0
File: .cursor/rules/agent-core.mdc:0-0
Timestamp: 2026-01-16T14:33:39.551Z
Learning: Applies to **/*.{ts,tsx}?(test|example|spec) : When testing inference LLM, always use full model names from `agents/src/inference/models.ts` (e.g., 'openai/gpt-4o-mini' instead of 'gpt-4o-mini')
Applied to files:
agents/src/ipc/inference_proc_lazy_main.ts
🧬 Code graph analysis (1)
agents/src/ipc/job_proc_lazy_main.ts (2)
agents/src/job.ts (1)
agent(159-161)agents/src/generator.ts (1)
isAgent(16-24)
🔇 Additional comments (1)
agents/src/ipc/job_proc_lazy_main.ts (1)
159-163: LGTM — ESM/CJS resolution logic is sound.The conditional correctly distinguishes between ESM (where
module.defaultis the agent directly) and CJS double-wrapping (wheremodule.default.defaultholds it). TheisAgentguard on line 161 properly catches the case where the agent export is an object (not a function) conforming to theAgentinterface, and the validation on line 164 acts as a safety net for any unrecognized shape.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Description
Support for CJS environments was broken
Changes Made
The changes ensure that we can handle default imports also from CJS modules
Pre-Review Checklist
Testing
restaurant_agent.tsandrealtime_agent.tswork properly (for major changes)Additional Notes
Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.
Summary by CodeRabbit
Bug Fixes
Chores