Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/starter-templates/next-js-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build --turbopack",
"build": "next build",
"start": "next start"
},
"dependencies": {
Expand Down
12 changes: 1 addition & 11 deletions apps/starter-templates/next-js-starter/src/app/demo/_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,8 @@

import { getRootAgent } from "@/agents";

let agentRunner: Awaited<ReturnType<typeof getRootAgent>>["runner"];

async function getAgentRunner() {
if (!agentRunner) {
const { runner } = await getRootAgent();
agentRunner = runner;
}
return agentRunner;
}

export async function askAgent(message: string) {
const runner = await getAgentRunner();
const { runner } = await getRootAgent();
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.

medium

Calling getRootAgent() on every request might introduce performance overhead if agent initialization is a costly process. While this change correctly fixes a state-sharing bug from the previous implementation by ensuring request isolation, this approach could become a bottleneck in a production application.

A potential optimization would be to cache the agent definition and only create a new runner or session for each request. This would depend on the specific API provided by the @iqai/adk library for creating sessions from a pre-built agent.

const result = await runner.ask(message);
return result;
}
92 changes: 0 additions & 92 deletions apps/starter-templates/next-js-starter/src/components/ui/card.tsx

This file was deleted.