Skip to content

upgrade adk-ts v0.1.1 & use agent builder pattern#1

Merged
GPSxtreme merged 4 commits intomainfrom
migration
Jul 3, 2025
Merged

upgrade adk-ts v0.1.1 & use agent builder pattern#1
GPSxtreme merged 4 commits intomainfrom
migration

Conversation

@GPSxtreme
Copy link
Copy Markdown
Contributor

@GPSxtreme GPSxtreme commented Jul 2, 2025

Closes https://github.com/IQAIcom/issues/issues/356 when this PR merged.

Changes

  • update adk-ts version
  • update agents to use agent builder pattern

@GPSxtreme GPSxtreme requested a review from Royal-lobster July 2, 2025 11:20
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @GPSxtreme, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on a significant upgrade of the @iqai/adk dependency to version 0.1.1 and a comprehensive refactoring of how agents are defined and instantiated. The codebase now leverages the new AgentBuilder pattern, streamlining agent configuration and aligning with the latest SDK capabilities. This change impacts all agent definitions and the main execution loop, ensuring compatibility and taking advantage of the updated framework.

Highlights

  • Dependency Upgrade: The @iqai/adk dependency has been upgraded from version ^0.0.4 to ^0.1.1, bringing in new features and potentially breaking changes from the updated SDK.
  • Agent Builder Pattern Adoption: The core change involves refactoring all agent instantiations (AtpLoggerAgent, NotifierAgent, WatcherAgent, and SophiaAgent) to utilize the new AgentBuilder pattern provided by the updated @iqai/adk SDK. This shifts agent creation from class-based constructors to a fluent builder API, enhancing readability and configuration.
  • Agent Function Signatures: Individual agent definitions have been transformed from classes (export class AgentName) into asynchronous functions (export async function agentName(...)) that return a BuiltAgent instance, aligning with the new builder pattern.
  • Agent Execution Flow Update: The runCycle function in src/runner.ts has been updated to accommodate the new BuiltAgent structure, specifically using runner.runAsync for agent execution and iterating over events to process results, replacing the previous agent.run method.
  • Watcher Agent Timeframe Adjustment: The WatcherAgent's GET_USER_WIKI_ACTIVITIES tool call now requests activities within a 50-minute timeframe, increased from the previous 10 minutes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The code changes introduce the agent builder pattern and upgrade the adk-ts dependency. There are a few issues that should be addressed to improve the code's correctness and maintainability, including a logic error in the watcher agent that could lead to reprocessing activities, a redundant check in src/runner.ts, and a hardcoded user ID in src/agents/sophia.ts.


Your only work is to do the below:
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 10 minutes (pass it as seconds)
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 50 minutes (pass it as seconds)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

The timeframe for fetching user wiki activities is set to 50 minutes, but the cron job in src/env.ts is configured to run every 10 minutes (*/10 * * * *). This mismatch will cause the agent to re-process activities from the overlapping 40-minute window in each run, leading to duplicate logs and notifications.

To prevent this, the timeframe should align with the cron schedule.

Suggested change
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 50 minutes (pass it as seconds)
- call the GET_USER_WIKI_ACTIVITIES tool with timeframe as 10 minutes (pass it as seconds)

}
`)
.withTools(...iqWikiTools)
.withQuickSession("sophia", "uid_1234")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The watcherAgent is being built with its own session via withQuickSession. However, watcherAgent is used as a node within the sophiaAgent langgraph, which manages the overall session. Sub-agents within a graph should not create their own sessions, as this is redundant and can lead to unexpected behavior or state conflicts. The session management should be handled exclusively by the top-level sophiaAgent.

src/runner.ts Outdated
Comment on lines +27 to +31
if (telegramConfig) {
telegramToolset = new McpToolset(telegramConfig);
telegramTools = await telegramToolset.getTools();
console.log("🔗 Telegram tools initialized");
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The if (telegramConfig) check is redundant. The createTelegramConfig function always returns an McpConfig object. If the required environment variables (TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID) are missing, the application will fail on startup due to the Zod schema validation in src/env.ts.

If the intent is to make the Telegram integration optional, the environment variables should be marked as optional in src/env.ts, and createTelegramConfig should be updated to return undefined when they are not set. Otherwise, this block can be simplified for clarity.

telegramToolset = new McpToolset(telegramConfig);
	telegramTools = await telegramToolset.getTools();
	console.log("🔗 Telegram tools initialized");

}
"watcher",
)
.withQuickSession("sophia", "uid_1234")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The agent session is initialized with a hardcoded user ID "uid_1234". This is also hardcoded in src/runner.ts. Using a static ID means all agent runs will be associated with the same user, which can make debugging and tracking difficult. It also limits the agent's reusability.

Consider using a dynamically generated or configurable user ID for each run.

@GPSxtreme GPSxtreme merged commit 4986275 into main Jul 3, 2025
1 check passed
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