Support direct AgentSession kwargs in AgentPool.add#6
Support direct AgentSession kwargs in AgentPool.add#6mahimairaja wants to merge 2 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdded per-agent Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Pool as AgentPool
participant Config as AgentConfig
participant Helper as _build_agent<br/>_session_kwargs
participant Session as AgentSession
User->>Pool: add(session_kwargs={...},<br/>**agent_session_kwargs)
Pool->>Pool: _merge_session_kwargs(...)
Pool->>Config: Create config with<br/>merged session_kwargs
Note over Pool,Config: Configuration Phase Complete
User->>Pool: _handle_session(ctx)
Pool->>Helper: _build_agent_session_kwargs(config, ctx)
Helper->>Helper: Deep-copy config kwargs
Helper->>Helper: Apply defaults for stt/llm/tts
Helper->>Helper: Apply defaults from ctx.userdata<br/>(vad, turn_detection)
Helper-->>Pool: Final kwargs dict
Pool->>Session: AgentSession(**final_kwargs)
Session-->>User: Ready session
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~23 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Motivation
AgentSessionoptions directly toAgentPool.add()while preserving the existingsession_kwargsmapping for backward compatibility.stt,llm,tts) as the highest-precedence public API and make merging/precedence explicit to avoid surprising overrides.Description
AgentPool.add()signature to acceptsession_kwargs: Mapping[str, Any] | Noneand**agent_session_kwargsand added validation thatsession_kwargsmust be a mapping when provided.session_kwargstoAgentConfigand implemented_merge_session_kwargs()to merge mapping-based options with direct kwargs where direct kwargs override the mapping.AgentSessionkeyword arguments in_build_agent_session_kwargs()so pool defaults (stt,llm,tts,vad,turn_detection) are only used when callers did not provide values._handle_session()to createAgentSessionviaAgentSession(**self._build_agent_session_kwargs(config, ctx))and updated the README with an example and documented precedence rules.Testing
tests/test_pool.py(merging behavior, precedence, rejection of non-mappingsession_kwargs, and verification of the kwargs passed intoAgentSession) and extended the local LiveKit stub intests/conftest.pyto expose the created session instance for assertions.pytest tests/test_pool.py tests/test_discovery.py tests/test_cli.pywith all tests passing (22 passed).ruffon modified files and received no issues.Codex Task
Summary by CodeRabbit
Release Notes
New Features
Documentation