fix(agentos): sync BeeOS runtime worktree to latest main#32
fix(agentos): sync BeeOS runtime worktree to latest main#32wunitb wants to merge 1 commit intoiii-hq:mainfrom
Conversation
|
@wunitb is attempting to deploy a commit to the motia Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis pull request implements TypeScript type safety improvements across the codebase, converting API schemas from array-based to object-based formats, adding explicit type annotations to test mocks and runtime variables, introducing type assertions in trigger-result handling, and refining function signatures for trigger handlers and metric recording. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
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
🧹 Nitpick comments (1)
src/session-lifecycle.ts (1)
127-148: Consider usingStoredReactiontype in map callbacks for consistency.The
safeCall<StoredReaction[]>generic typing is a good improvement. However, the subsequent map operations on lines 147-148 still use(r: any)instead of(r: StoredReaction), which partially undermines the type safety benefit.♻️ Suggested refinement
const reactions = [ - ...agentReactions.map((r: any) => ({ ...r, _scope: `lifecycle_reactions:${agentId}` })), - ...globalReactions.map((r: any) => ({ ...r, _scope: "lifecycle_reactions" })), + ...agentReactions.map((r: StoredReaction) => ({ ...r, _scope: `lifecycle_reactions:${agentId}` })), + ...globalReactions.map((r: StoredReaction) => ({ ...r, _scope: "lifecycle_reactions" })), ];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/session-lifecycle.ts` around lines 127 - 148, The map callbacks currently type their parameters as (r: any) which weakens the earlier safeCall<StoredReaction[]> typing; update the two maps that build reactions from agentReactions and globalReactions to use (r: StoredReaction) (or infer the type) instead of any, so the resulting array construction (the spread into reactions) preserves type safety for StoredReaction and its added _scope property; ensure the StoredReaction type is in scope where the maps run and adjust imports if necessary.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/llm-router.ts`:
- Around line 305-314: The tools mapping in the body.tools block currently
filters by t.id and drops tools that only have function_id; update the filter
and mapping to accept either t.id or t.function_id (mirroring callAnthropic's id
resolution) so tools with only function_id are included, i.e., change the
predicate to check for (t.id || t.function_id) being a non-empty string and
derive the function name using that resolved identifier (replace :: with _), and
keep the rest of the function schema construction unchanged so callOpenAICompat
receives the same tool shape as callAnthropic.
---
Nitpick comments:
In `@src/session-lifecycle.ts`:
- Around line 127-148: The map callbacks currently type their parameters as (r:
any) which weakens the earlier safeCall<StoredReaction[]> typing; update the two
maps that build reactions from agentReactions and globalReactions to use (r:
StoredReaction) (or infer the type) instead of any, so the resulting array
construction (the spread into reactions) preserves type safety for
StoredReaction and its added _scope property; ensure the StoredReaction type is
in scope where the maps run and adjust imports if necessary.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 201b0fd0-3c94-4924-bcc8-b98cde6f79fa
📒 Files selected for processing (15)
docs/reviews/sentrux/2026-04-04-022609-codex-agentos-tsc-cleanup.mddocs/reviews/sentrux/2026-04-04-204700-codex-agentos-runtime-latest-main-sync.mdsrc/__tests__/mcp-client.test.tssrc/__tests__/security-headers.test.tssrc/__tests__/skillkit-bridge.test.tssrc/__tests__/streaming.test.tssrc/api.tssrc/context-cache.tssrc/cron.tssrc/evolve.tssrc/llm-router.tssrc/memory.tssrc/session-lifecycle.tssrc/shared/metrics.tssrc/types.ts
| body.tools = req.tools | ||
| .filter((t): t is typeof t & { id: string } => typeof t?.id === "string" && t.id.length > 0) | ||
| .map((t) => ({ | ||
| type: "function", | ||
| function: { | ||
| name: t.id.replace(/::/g, "_"), | ||
| description: t.description || t.id, | ||
| parameters: { type: "object", properties: {} }, | ||
| }, | ||
| })); | ||
| })); |
There was a problem hiding this comment.
Inconsistent tool identifier handling will silently drop tools with only function_id.
callAnthropic (line 222) correctly handles both identifiers via t.id || t.function_id || "unknown", but callOpenAICompat filters out tools that lack an id property. Per the context snippet from src/agent-core.ts:129-132, tools may legitimately have only function_id set. These tools will be silently excluded when using OpenAI-compatible providers.
🔧 Proposed fix to align with callAnthropic
if (req.tools?.length) {
body.tools = req.tools
- .filter((t): t is typeof t & { id: string } => typeof t?.id === "string" && t.id.length > 0)
- .map((t) => ({
+ .filter((t) => {
+ const toolId = t.id || t.function_id;
+ return typeof toolId === "string" && toolId.length > 0;
+ })
+ .map((t) => {
+ const toolId = (t.id || t.function_id)!;
+ return {
type: "function",
function: {
- name: t.id.replace(/::/g, "_"),
- description: t.description || t.id,
+ name: toolId.replace(/::/g, "_"),
+ description: t.description || toolId,
parameters: { type: "object", properties: {} },
},
- }));
+ };
+ });
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/llm-router.ts` around lines 305 - 314, The tools mapping in the
body.tools block currently filters by t.id and drops tools that only have
function_id; update the filter and mapping to accept either t.id or
t.function_id (mirroring callAnthropic's id resolution) so tools with only
function_id are included, i.e., change the predicate to check for (t.id ||
t.function_id) being a non-empty string and derive the function name using that
resolved identifier (replace :: with _), and keep the rest of the function
schema construction unchanged so callOpenAICompat receives the same tool shape
as callAnthropic.
Summary
origin/main(c664876) and reapply the runtime TypeScript contract cleanup needed by BeeOSsrc/llm-router.tsandsrc/memory.tsso runtimetscis clean againdocs/reviews/sentrux/2026-04-04-204700-codex-agentos-runtime-latest-main-sync.mdTest Plan
npx tsc -p tsconfig.json --noEmit --pretty falsenpm test -- src/__tests__/mcp-client.test.ts src/__tests__/security-headers.test.ts src/__tests__/skillkit-bridge.test.ts src/__tests__/streaming.test.ts src/__tests__/llm-router.test.ts src/__tests__/session-lifecycle.test.ts src/__tests__/cron.test.ts src/__tests__/api.test.tsgit diff --checkSummary by CodeRabbit
New Features
Documentation
Type Safety