Conversation
There was a problem hiding this comment.
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/adkdependency has been upgraded from version^0.0.4to^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, andSophiaAgent) to utilize the newAgentBuilderpattern provided by the updated@iqai/adkSDK. 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 aBuiltAgentinstance, aligning with the new builder pattern. - Agent Execution Flow Update: The
runCyclefunction insrc/runner.tshas been updated to accommodate the newBuiltAgentstructure, specifically usingrunner.runAsyncfor agent execution and iterating over events to process results, replacing the previousagent.runmethod. - Watcher Agent Timeframe Adjustment: The
WatcherAgent'sGET_USER_WIKI_ACTIVITIEStool 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
-
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. ↩
There was a problem hiding this comment.
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.
src/agents/watcher.ts
Outdated
|
|
||
| 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) |
There was a problem hiding this comment.
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.
| - 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) |
src/agents/watcher.ts
Outdated
| } | ||
| `) | ||
| .withTools(...iqWikiTools) | ||
| .withQuickSession("sophia", "uid_1234") |
There was a problem hiding this comment.
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
| if (telegramConfig) { | ||
| telegramToolset = new McpToolset(telegramConfig); | ||
| telegramTools = await telegramToolset.getTools(); | ||
| console.log("🔗 Telegram tools initialized"); | ||
| } |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
Closes https://github.com/IQAIcom/issues/issues/356 when this PR merged.
Changes