Skip to content

Move default template from agent pattern to route-only#1386

Open
potofpie wants to merge 1 commit intomainfrom
template-route-only
Open

Move default template from agent pattern to route-only#1386
potofpie wants to merge 1 commit intomainfrom
template-route-only

Conversation

@potofpie
Copy link
Copy Markdown
Member

@potofpie potofpie commented Apr 15, 2026

Summary

  • Removes the createAgent() indirection from the default template so all translation logic lives directly in the API route handlers
  • Cleans up the base template's phantom @agent/hello import
  • Drops eval dependencies (@agentuity/evals, groq-sdk) that are no longer needed

What changed

File Change
templates/default/src/agent/** Deleted — agent definition, evals, and registry override
templates/default/src/api/index.ts Rewrote with inline translation logic using c.var.* for services and standalone validator()
templates/_base/src/api/index.ts Replaced @agent/hello import with simple GET /hello route
templates/default/package.overlay.json Removed @agentuity/evals and groq-sdk
templates/default/src/web/App.tsx Updated "Next Steps" copy to reference routes instead of agents

The response shapes are identical so the frontend UI works unchanged. The base app.ts still imports the empty agents array — no changes needed there.

Summary by CodeRabbit

  • API Updates

    • Changed /hello endpoint from POST to GET
    • Refactored /translate to use direct OpenAI integration
  • Improvements

    • Streamlined template architecture by removing agent framework dependencies
    • Reduced package footprint for lighter implementation
  • Documentation

    • Updated guidance to reflect new API-focused workflow

Replace the createAgent() indirection with inline route handlers so the
default template is simpler and easier to follow. Translation logic now
lives directly in the API routes using c.var.* for services.

- Remove src/agent/translate/ (agent + evals)
- Inline translation logic into POST /translate route handler
- Clean up base template's phantom @agent/hello import
- Drop @agentuity/evals and groq-sdk dependencies
- Update App.tsx next-steps copy to reference routes
@agentuity-agent
Copy link
Copy Markdown

agentuity-agent bot commented Apr 15, 2026

The latest Agentuity deployment details.

Project Deployment Preview Updated (UTC)
docs 🔴 Failed (deploy_f57dadcefde72a9b67a262912c021187) - 2026-04-15T15:18:58Z

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Refactored the default template to shift from an agent-based architecture to a route-based architecture. Removed agent-related files and dependencies, updated the API to use direct OpenAI calls, and modified documentation references.

Changes

Cohort / File(s) Summary
Template API Routes
templates/_base/src/api/index.ts, templates/default/src/api/index.ts
Base template /hello route changed from POST with validation to GET with static response. Default template /translate endpoint refactored to use direct OpenAI calls instead of agent framework; added HistoryEntry schema and updated validators for structured input/output.
Dependency Updates
templates/default/package.overlay.json
Removed @agentuity/evals and groq-sdk dependencies; retained openai only.
Agent Framework Removal
templates/default/src/agent/index.ts, templates/default/src/agent/translate/index.ts, templates/default/src/agent/translate/eval.ts
Entirely removed agent registry, translate agent implementation, and evaluation functions; eliminates agent-based control flow, schema definitions, and Groq client usage.
Documentation Updates
templates/default/src/web/App.tsx
Updated onboarding guide from "Customize your agent" to "Customize your routes"; changed instructional text to reference src/api/index.ts instead of agent file and adjusted Workbench description.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


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

@github-actions
Copy link
Copy Markdown

📦 Canary Packages Published

version: 2.0.9-d315916

Packages
Package Version URL
@agentuity/drizzle 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-drizzle-2.0.9-d315916.tgz
@agentuity/opencode 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-opencode-2.0.9-d315916.tgz
@agentuity/webhook 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-webhook-2.0.9-d315916.tgz
@agentuity/keyvalue 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-keyvalue-2.0.9-d315916.tgz
@agentuity/coder 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-2.0.9-d315916.tgz
@agentuity/queue 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-queue-2.0.9-d315916.tgz
@agentuity/db 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-db-2.0.9-d315916.tgz
@agentuity/workbench 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-workbench-2.0.9-d315916.tgz
@agentuity/vector 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-vector-2.0.9-d315916.tgz
@agentuity/runtime 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-runtime-2.0.9-d315916.tgz
@agentuity/email 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-email-2.0.9-d315916.tgz
@agentuity/auth 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-auth-2.0.9-d315916.tgz
@agentuity/schema 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schema-2.0.9-d315916.tgz
@agentuity/postgres 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-postgres-2.0.9-d315916.tgz
@agentuity/evals 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-evals-2.0.9-d315916.tgz
@agentuity/schedule 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schedule-2.0.9-d315916.tgz
@agentuity/react 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-react-2.0.9-d315916.tgz
@agentuity/coder-tui 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-tui-2.0.9-d315916.tgz
@agentuity/sandbox 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-sandbox-2.0.9-d315916.tgz
@agentuity/frontend 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-frontend-2.0.9-d315916.tgz
@agentuity/cli 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-cli-2.0.9-d315916.tgz
@agentuity/core 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-core-2.0.9-d315916.tgz
@agentuity/task 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-task-2.0.9-d315916.tgz
@agentuity/server 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-server-2.0.9-d315916.tgz
@agentuity/claude-code 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-claude-code-2.0.9-d315916.tgz
@agentuity/migrate 2.0.9-d315916 https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-migrate-2.0.9-d315916.tgz
Install

Add to your package.json:

{
  "dependencies": {
    "@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-drizzle-2.0.9-d315916.tgz",
    "@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-opencode-2.0.9-d315916.tgz",
    "@agentuity/webhook": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-webhook-2.0.9-d315916.tgz",
    "@agentuity/keyvalue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-keyvalue-2.0.9-d315916.tgz",
    "@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-2.0.9-d315916.tgz",
    "@agentuity/queue": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-queue-2.0.9-d315916.tgz",
    "@agentuity/db": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-db-2.0.9-d315916.tgz",
    "@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-workbench-2.0.9-d315916.tgz",
    "@agentuity/vector": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-vector-2.0.9-d315916.tgz",
    "@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-runtime-2.0.9-d315916.tgz",
    "@agentuity/email": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-email-2.0.9-d315916.tgz",
    "@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-auth-2.0.9-d315916.tgz",
    "@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schema-2.0.9-d315916.tgz",
    "@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-postgres-2.0.9-d315916.tgz",
    "@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-evals-2.0.9-d315916.tgz",
    "@agentuity/schedule": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schedule-2.0.9-d315916.tgz",
    "@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-react-2.0.9-d315916.tgz",
    "@agentuity/coder-tui": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-tui-2.0.9-d315916.tgz",
    "@agentuity/sandbox": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-sandbox-2.0.9-d315916.tgz",
    "@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-frontend-2.0.9-d315916.tgz",
    "@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-cli-2.0.9-d315916.tgz",
    "@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-core-2.0.9-d315916.tgz",
    "@agentuity/task": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-task-2.0.9-d315916.tgz",
    "@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-server-2.0.9-d315916.tgz",
    "@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-claude-code-2.0.9-d315916.tgz",
    "@agentuity/migrate": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-migrate-2.0.9-d315916.tgz"
  }
}

Or install directly:

bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-drizzle-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-opencode-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-webhook-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-keyvalue-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-queue-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-db-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-workbench-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-vector-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-runtime-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-email-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-auth-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schema-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-postgres-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-evals-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-schedule-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-react-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-coder-tui-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-sandbox-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-frontend-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-cli-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-core-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-task-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-server-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-claude-code-2.0.9-d315916.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/2.0.9-d315916/agentuity-migrate-2.0.9-d315916.tgz

Copy link
Copy Markdown
Contributor

@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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@templates/_base/src/api/index.ts`:
- Around line 4-5: The route was changed to GET+JSON which breaks the generated
client used by the shipped frontend; revert the `/hello` route to a POST that
returns plain text so client.hello.$post(...) and res.text() still work. Modify
the Hono route definition on the `api` instance from `.get('/hello', ...)` to
`.post('/hello', (c) => c.text(...))`, ensuring the handler reads request body
if needed and returns a text/plain response (use `c.text(...)`) so the generated
client preserves its `$post` method.

In `@templates/default/src/api/index.ts`:
- Around line 97-113: The response currently uses the windowed history
(c.var.thread.state.push('history', newEntry, 5) and history = await
c.var.thread.state.get('history')) to compute translationCount, which caps at 5;
fix by either persisting a separate total counter in thread state (e.g.
increment a distinct key like 'totalTranslations' on each translation using the
thread state API and return that value as translationCount) or rename the
returned field to reflect the windowed value (e.g. windowedTranslationCount) and
keep translationCount representing the persisted total; update the return object
accordingly and ensure you modify the code paths that push history
(c.var.thread.state.push) to also update the chosen counter key.
- Around line 73-76: The call to openai.chat.completions.create in the handler
lacks error handling and should be wrapped in a try-catch that normalizes
provider failures into a StructuredError; import StructuredError from
'@agentuity/core', define an OpenAIError = StructuredError('OpenAIError') with
fields { errorCode?: string; provider: string }, then surround the
openai.chat.completions.create({ model, messages: [{ role: 'user', content:
prompt }] }) call with try/catch and on error throw new OpenAIError({ message:
err instanceof Error ? err.message : 'OpenAI provider failed', errorCode: (err
as any)?.code, provider: 'openai', cause: err }); ensure the rest of the handler
continues inside the try block.

In `@templates/default/src/web/App.tsx`:
- Around line 324-329: The hero copy and helper text in the App React component
still reference the removed “translation agent” and “agent logs” patterns;
update the JSX in the App component (look for the section with key:
'customize-routes' and the <code>src/api/index.ts</code> hint) to use
route-focused copy instead—replace occurrences of "translation agent", "agent",
and "agent logs" with wording like "routes", "request handling", and "request
logs" (and update the hero title/paragraph elsewhere in the same App component
to match). Search within the App function/JSX for any remaining strings
"translation agent" or "agent logs" and edit them to consistently describe
customizing routes and request handling across the screen.
🪄 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: bde64ddb-2772-4077-a0aa-92a9e896dfd3

📥 Commits

Reviewing files that changed from the base of the PR and between 41febb8 and d315916.

📒 Files selected for processing (7)
  • templates/_base/src/api/index.ts
  • templates/default/package.overlay.json
  • templates/default/src/agent/index.ts
  • templates/default/src/agent/translate/eval.ts
  • templates/default/src/agent/translate/index.ts
  • templates/default/src/api/index.ts
  • templates/default/src/web/App.tsx
💤 Files with no reviewable changes (3)
  • templates/default/src/agent/index.ts
  • templates/default/src/agent/translate/eval.ts
  • templates/default/src/agent/translate/index.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: Package Installation & Usage Test
  • GitHub Check: Windows WSL CLI Smoke Test
  • GitHub Check: Queue CLI Tests
  • GitHub Check: Build
  • GitHub Check: Playwright E2E Smoke Test
  • GitHub Check: Pack & Upload
  • GitHub Check: Cloud Deployment Tests
  • GitHub Check: Framework Integration Tests (TanStack & Next.js)
  • GitHub Check: Template Integration Tests
  • GitHub Check: Sandbox CLI Tests
  • GitHub Check: Postgres SSL Integration Test
  • GitHub Check: Standalone Agent Test
  • GitHub Check: Queue SDK Tests
  • GitHub Check: SDK Integration Test Suite
  • GitHub Check: Storage CLI Tests
🧰 Additional context used
📓 Path-based instructions (4)
templates/_base/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (templates/_base/AGENTS.md)

Use Bun instead of NodeJS and TypeScript for all source code

Files:

  • templates/_base/src/api/index.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5

Files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
  • templates/default/src/web/App.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
  • templates/default/src/web/App.tsx
**/index.ts

📄 CodeRabbit inference engine (AGENTS.md)

Use named exports from package index.ts files

Files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
🧠 Learnings (6)
📚 Learning: 2025-12-19T14:19:33.765Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 259
File: packages/cli/src/cmd/build/vite/registry-generator.ts:306-312
Timestamp: 2025-12-19T14:19:33.765Z
Learning: Route files under src/api should use the .ts extension only (no .tsx) and regex patterns for such paths should anchor to \.ts$ (e.g., /\/.ts$/). Agent files may support both .ts and .tsx, but route files in the Agentuity SDK codebase are restricted to .ts. This guideline applies to all similar route files under src/api across the repository.

Applied to files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.

Applied to files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
📚 Learning: 2026-02-25T22:13:01.823Z
Learnt from: Huijiro
Repo: agentuity/sdk PR: 1063
File: apps/testing/vite-rsc-app/agentuity/src/api/index.ts:26-26
Timestamp: 2026-02-25T22:13:01.823Z
Learning: Agentuity SDK requires default exports for API route files (e.g., src/api/**/index.ts and src/api/**/route.ts) because the CLI's generateRouteRegistry relies on default exports to discover routes. Using named exports will skip route generation and lead to runtime 500 errors. This overrides typical guidance about named exports in index.ts files; ensure a default export is present in all relevant API route files under src/api/**/.

Applied to files:

  • templates/_base/src/api/index.ts
  • templates/default/src/api/index.ts
📚 Learning: 2026-01-06T03:11:55.300Z
Learnt from: mcongrove
Repo: agentuity/sdk PR: 396
File: templates/default/src/web/App.tsx:111-111
Timestamp: 2026-01-06T03:11:55.300Z
Learning: In this repository's default template (Tailwind CSS v4 via tailwindcss/vite), gradient utilities such as bg-linear-to-*, bg-radial, and bg-conic are valid. Do not flag or replace these with bg-gradient-to-* in template files under templates/, including templates/default/src/web/App.tsx. Use bg-* utilities appropriate to Tailwind v4.

Applied to files:

  • templates/default/src/web/App.tsx
📚 Learning: 2026-01-06T03:11:55.300Z
Learnt from: mcongrove
Repo: agentuity/sdk PR: 396
File: templates/default/src/web/App.tsx:111-111
Timestamp: 2026-01-06T03:11:55.300Z
Learning: In templates/default/src/web/App.tsx, keep using the Tailwind v4 class bg-linear-to-r for the background gradient. Do not suggest changing it to bg-gradient-to-r. This is a file-specific convention based on the project’s Tailwind version; for other files, verify the Tailwind version before proposing class changes.

Applied to files:

  • templates/default/src/web/App.tsx
📚 Learning: 2026-01-09T16:26:51.893Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 523
File: templates/_base/src/web/frontend.tsx:13-35
Timestamp: 2026-01-09T16:26:51.893Z
Learning: In web frontend code, prefer using the built-in Error class for runtime errors. Do not throw or re-export StructuredError from agentuity/core in web app code. Replace instances of StructuredError with new Error or custom error types that extend Error; ensure error handling logic remains intact and that error messages are descriptive. This guideline applies to all web UI TypeScript/TSX files that run in the browser and import StructuredError from agentuity/core.

Applied to files:

  • templates/default/src/web/App.tsx

Comment on lines +4 to +5
const api = new Hono<Env>().get('/hello', (c) => {
return c.json({ message: 'Hello from Agentuity!' });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Keep /hello compatible with the shipped base frontend.

templates/_base/src/web/App.tsx:13-21 still calls client.hello.$post({ json: input }) and reads res.text(). Changing this route to GET + JSON removes the generated client's $post method and breaks the base template unless the frontend is updated in the same PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/_base/src/api/index.ts` around lines 4 - 5, The route was changed
to GET+JSON which breaks the generated client used by the shipped frontend;
revert the `/hello` route to a POST that returns plain text so
client.hello.$post(...) and res.text() still work. Modify the Hono route
definition on the `api` instance from `.get('/hello', ...)` to `.post('/hello',
(c) => c.text(...))`, ensuring the handler reads request body if needed and
returns a text/plain response (use `c.text(...)`) so the generated client
preserves its `$post` method.

Comment on lines +73 to +76
const completion = await openai.chat.completions.create({
model,
messages: [{ role: 'user', content: prompt }],
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C2 "StructuredError" --glob "**/*.{ts,tsx}"
rg -n -C2 "from '@agentuity/core'" --glob "**/*.{ts,tsx}"

Repository: agentuity/sdk

Length of output: 50372


🏁 Script executed:

cd templates/default && find . -name "index.ts" -path "*/src/api/*" | head -5

Repository: agentuity/sdk

Length of output: 75


🏁 Script executed:

wc -l templates/default/src/api/index.ts

Repository: agentuity/sdk

Length of output: 95


🏁 Script executed:

cat -n templates/default/src/api/index.ts

Repository: agentuity/sdk

Length of output: 5768


🏁 Script executed:

rg "StructuredError" templates/default --glob "**/*.{ts,tsx}" -n

Repository: agentuity/sdk

Length of output: 39


🏁 Script executed:

rg "from '@agentuity/core'" templates/default --glob "**/*.{ts,tsx}" -n

Repository: agentuity/sdk

Length of output: 39


Wrap provider failures in StructuredError.

The openai.chat.completions.create() call at lines 73–76 has no error handling. Failures (auth, network, rate-limiting, etc.) will bubble as unhandled rejections, producing generic 500 responses instead of a structured API error shape. Per coding guidelines for **/*.{ts,tsx}, wrap the call in a try-catch and normalize errors using StructuredError from @agentuity/core:

import { StructuredError } from '@agentuity/core';

const OpenAIError = StructuredError('OpenAIError')<{
	errorCode?: string;
	provider: string;
}>();

try {
	const completion = await openai.chat.completions.create({
		model,
		messages: [{ role: 'user', content: prompt }],
	});
	// ... rest of handler
} catch (err) {
	throw new OpenAIError({
		message: err instanceof Error ? err.message : 'OpenAI provider failed',
		errorCode: err?.code,
		provider: 'openai',
		cause: err,
	});
}

This ensures generated apps get a consistent, structured error response from your routes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/src/api/index.ts` around lines 73 - 76, The call to
openai.chat.completions.create in the handler lacks error handling and should be
wrapped in a try-catch that normalizes provider failures into a StructuredError;
import StructuredError from '@agentuity/core', define an OpenAIError =
StructuredError('OpenAIError') with fields { errorCode?: string; provider:
string }, then surround the openai.chat.completions.create({ model, messages: [{
role: 'user', content: prompt }] }) call with try/catch and on error throw new
OpenAIError({ message: err instanceof Error ? err.message : 'OpenAI provider
failed', errorCode: (err as any)?.code, provider: 'openai', cause: err });
ensure the rest of the handler continues inside the try block.

Comment on lines +97 to +113
// Append to history (sliding window, keeps last 5 entries)
await c.var.thread.state.push('history', newEntry, 5);

const history = (await c.var.thread.state.get<HistoryEntry[]>('history')) ?? [];

c.var.logger.info('Translation complete', {
tokens,
historyCount: history.length,
});

return c.json({
history,
sessionId: c.var.sessionId,
threadId: c.var.thread.id,
tokens,
translation,
translationCount: history.length,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

translationCount tops out at the 5-entry history cap.

history is intentionally truncated with push('history', newEntry, 5), but translationCount is derived from history.length and documented as the total translations in the thread. After the sixth request it will stay at 5, and GET /translate/history will return the same capped count downstream. Either persist a separate counter in thread state or rename the field/description to match the windowed behavior.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/src/api/index.ts` around lines 97 - 113, The response
currently uses the windowed history (c.var.thread.state.push('history',
newEntry, 5) and history = await c.var.thread.state.get('history')) to compute
translationCount, which caps at 5; fix by either persisting a separate total
counter in thread state (e.g. increment a distinct key like 'totalTranslations'
on each translation using the thread state API and return that value as
translationCount) or rename the returned field to reflect the windowed value
(e.g. windowedTranslationCount) and keep translationCount representing the
persisted total; update the return object accordingly and ensure you modify the
code paths that push history (c.var.thread.state.push) to also update the chosen
counter key.

Comment on lines +324 to +329
key: 'customize-routes',
title: 'Customize your routes',
text: (
<>
Edit <code className="text-white">src/agent/translate/agent.ts</code>{' '}
to change how your agent responds.
Edit <code className="text-white">src/api/index.ts</code> to change
how your app handles requests.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Finish the route-only copy refresh across this screen.

This step now points to routes, but the hero copy and helper text earlier in templates/default/src/web/App.tsx still talk about a “translation agent” and “agent logs”. The generated starter will still teach the removed pattern unless those strings are updated too.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/default/src/web/App.tsx` around lines 324 - 329, The hero copy and
helper text in the App React component still reference the removed “translation
agent” and “agent logs” patterns; update the JSX in the App component (look for
the section with key: 'customize-routes' and the <code>src/api/index.ts</code>
hint) to use route-focused copy instead—replace occurrences of "translation
agent", "agent", and "agent logs" with wording like "routes", "request
handling", and "request logs" (and update the hero title/paragraph elsewhere in
the same App component to match). Search within the App function/JSX for any
remaining strings "translation agent" or "agent logs" and edit them to
consistently describe customizing routes and request handling across the screen.

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