Skip to content

fix(agentos): sync BeeOS runtime worktree to latest main#32

Open
wunitb wants to merge 1 commit intoiii-hq:mainfrom
wunitb:beeos-main-runtime-latest
Open

fix(agentos): sync BeeOS runtime worktree to latest main#32
wunitb wants to merge 1 commit intoiii-hq:mainfrom
wunitb:beeos-main-runtime-latest

Conversation

@wunitb
Copy link
Copy Markdown

@wunitb wunitb commented Apr 4, 2026

Summary

  • rebase the BeeOS runtime worktree onto latest origin/main (c664876) and reapply the runtime TypeScript contract cleanup needed by BeeOS
  • add the two remaining latest-main compatibility fixes in src/llm-router.ts and src/memory.ts so runtime tsc is clean again
  • keep a per-session verification artifact in docs/reviews/sentrux/2026-04-04-204700-codex-agentos-runtime-latest-main-sync.md

Test Plan

  • npx tsc -p tsconfig.json --noEmit --pretty false
  • npm 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.ts
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added configurable agent tier support (economy and premium options).
    • Enhanced LLM tool compatibility for flexible identifier handling.
  • Documentation

    • Added code review reports documenting TypeScript validation and runtime verification results.
  • Type Safety

    • Improved TypeScript type annotations across multiple modules for enhanced compile-time safety.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 4, 2026

@wunitb is attempting to deploy a commit to the motia Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Documentation & Review Reports
docs/reviews/sentrux/2026-04-04-022609-codex-agentos-tsc-cleanup.md, docs/reviews/sentrux/2026-04-04-204700-codex-agentos-runtime-latest-main-sync.md
Added two Sentrux review audit documents recording TypeScript compilation hygiene, test verification results, and runtime drift findings with recommended fixes.
Test Mock Signature Updates
src/__tests__/mcp-client.test.ts, src/__tests__/security-headers.test.ts, src/__tests__/skillkit-bridge.test.ts, src/__tests__/streaming.test.ts
Updated Vitest mock functions with explicit parameter types (_fnId?: string, _payload?: unknown) and return types (Promise<null> and void) to align with iii-sdk trigger dispatch patterns.
API Schema Format Conversion
src/api.ts
Converted request_format and response_format for four endpoints from array-based schemas to object-based schemas with explicit structure (type: "object", body arrays), including expanded nested choices specification in chat_completions response.
Type Assertion & Variable Typing
src/context-cache.ts, src/cron.ts, src/evolve.ts
Refactored variable type declarations from explicit const x: any[] = ... annotations to inline type assertions const x = (...) as any[]; fixed globalThis.vitest TypeScript complaints via typed alias approach.
Function Signatures & Type Definitions
src/llm-router.ts, src/memory.ts, src/session-lifecycle.ts, src/shared/metrics.ts, src/types.ts
Made tool identifier fields optional with dual-path support (id | function_id), added StoredReaction type with explicit generics, expanded TriggerVoidFn return to allow Promise<unknown>, and introduced optional agentTier property to AgentConfig.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 With twitching whiskers and careful sight,
I've tidied schemas from left to right!
No more ambiguous types in the fray,
Each trigger and promise now has its way,
The TypeScript forest blooms bright and clear,
Type safety prevails throughout the sphere! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(agentos): sync BeeOS runtime worktree to latest main' accurately summarizes the primary objective of rebasing the runtime worktree onto the latest main branch.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/session-lifecycle.ts (1)

127-148: Consider using StoredReaction type 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

📥 Commits

Reviewing files that changed from the base of the PR and between c664876 and a915aab.

📒 Files selected for processing (15)
  • docs/reviews/sentrux/2026-04-04-022609-codex-agentos-tsc-cleanup.md
  • docs/reviews/sentrux/2026-04-04-204700-codex-agentos-runtime-latest-main-sync.md
  • src/__tests__/mcp-client.test.ts
  • src/__tests__/security-headers.test.ts
  • src/__tests__/skillkit-bridge.test.ts
  • src/__tests__/streaming.test.ts
  • src/api.ts
  • src/context-cache.ts
  • src/cron.ts
  • src/evolve.ts
  • src/llm-router.ts
  • src/memory.ts
  • src/session-lifecycle.ts
  • src/shared/metrics.ts
  • src/types.ts

Comment on lines +305 to +314
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: {} },
},
}));
}));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant