-
Notifications
You must be signed in to change notification settings - Fork 5
Add Riza Agent #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Riza Agent #27
Conversation
WalkthroughThis change introduces a new AI agent project, "agent-riza," integrating Anthropic's Claude model with Riza's secure code execution API. The update adds configuration files, documentation, SDK and agent guidelines, and a TypeScript implementation that processes prompts, executes code in multiple languages, and formats the output for responses. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Agent (agent-riza)
participant Claude Model
participant Riza API
User->>Agent: Sends prompt
Agent->>Claude Model: Forwards prompt with system message and tool schema
Claude Model-->>Agent: Returns content blocks (text/tool_use)
loop For each block
alt Text block
Agent->>Agent: Append text to result
else Tool_use block ("code")
Agent->>Agent: Extract language and code
Agent->>Riza API: Execute code securely
Riza API-->>Agent: Return output/error
Agent->>Agent: Append output/error to result
end
end
Agent-->>User: Returns formatted response
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
🧹 Nitpick comments (14)
agents/agent-riza/.env.example (1)
2-2: Add a trailing newline.
A blank line at the end of this file satisfies POSIX requirements and silences the dotenv-linter warning.agents/agent-riza/tsconfig.json (3)
6-6: Remove unnecessary 'DOM' library reference.Since this agent runs in a Node.js environment, you can drop
"DOM"from thelibarray to avoid pulling in browser-specific APIs and reduce type-checking overhead.
18-18: Consider enablingresolveJsonModuleandisolatedModules.Adding
"resolveJsonModule": trueand"isolatedModules": trueundercompilerOptionsimproves JSON import support and enforces single-file transpilation compatibility, which is useful when bundling.
21-22: Exclude build output directories.In addition to
.agentuity, consider excluding your build artifacts (e.g.,dist/**) so editors and IDEs ignore generated code.agents/agent-riza/package.json (1)
22-23: Populate author and repository metadata.The
authorfield is empty and there are norepository/bugs/homepageentries. Adding these improves package discoverability and contributor guidance.agents/agent-riza/.cursor/rules/agent.mdc (4)
1-5: Validate frontmatter fields.Ensure the YAML frontmatter keys (
description,globs,alwaysApply) conform to your markdown-lint schema, and quote glob patterns if required by your processor.
9-15: Standardize bullet item phrasing.The list mixes imperatives and descriptive statements. For clarity, pick a single style (e.g., all starting with verbs) across all items.
18-24: Add explicit return type in example.In the sample agent, annotate the function return as
Promise<AgentResponse>to reinforce TypeScript best practices:export default async function Agent( req: AgentRequest, resp: AgentResponse, ctx: AgentContext ): Promise<AgentResponse> { return resp.json({ hello: 'world' }); }
28-29: Fix grammar in AgentRequest doc.Change "data has been passed to the Agent" to "data that have been passed to the Agent" for accuracy.
agents/agent-riza/README.md (2)
5-7: Clarify integration prerequisites.Specify the Anthropic SDK version, Node.js minimum version, and any required CLI tools so users can match the environment exactly.
42-47: Include dependency versions or referencepackage.json.Listing exact versions or directing users to
package.jsonhelps ensure they install matching dependencies.agents/agent-riza/agentuity.yaml (1)
13-15: Provide a meaningful project description.The
descriptionis empty—add a short summary to help collaborators and tooling understand the project’s purpose.agents/agent-riza/index.ts (1)
11-25: Guard is solid — consider unifying colour/error helpersThe runtime/env checks are correct. A tiny nicety would be to move the raw ANSI colour strings into a small
logError()/logWarn()helper so future messages stay consistent and easier to tweak.agents/agent-riza/src/agents/agent-riza/index.ts (1)
28-49: Schema looks good – minor tightening possibleThe tool schema is well-defined. Consider limiting
codelength (maxLength) to avoid accidentally shipping huge blobs to the exec endpoint.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
agents/agent-riza/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (13)
agents/agent-riza/.cursor/rules/agent.mdc(1 hunks)agents/agent-riza/.cursor/rules/agentuity.mdc(1 hunks)agents/agent-riza/.cursor/rules/sdk.mdc(1 hunks)agents/agent-riza/.editorconfig(1 hunks)agents/agent-riza/.env.example(1 hunks)agents/agent-riza/.gitignore(1 hunks)agents/agent-riza/README.md(1 hunks)agents/agent-riza/agentuity.yaml(1 hunks)agents/agent-riza/biome.json(1 hunks)agents/agent-riza/index.ts(1 hunks)agents/agent-riza/package.json(1 hunks)agents/agent-riza/src/agents/agent-riza/index.ts(1 hunks)agents/agent-riza/tsconfig.json(1 hunks)
🧰 Additional context used
🪛 dotenv-linter (3.3.0)
agents/agent-riza/.env.example
[warning] 2-2: [EndingBlankLine] No blank line at the end of the file
🔇 Additional comments (9)
agents/agent-riza/.env.example (1)
1-2: Env file is correctly scaffolded.
Including a placeholder forRIZA_API_KEYensures users fill in their own credentials.agents/agent-riza/biome.json (1)
1-27: Configuration looks good.
The Biome settings enable import organization, linting, and formatting rules consistent with the project’s standards.agents/agent-riza/.cursor/rules/agentuity.mdc (1)
1-10: Agentuity rule file is correctly defined.
This markdown config safely documents theagentuity.yamlguidelines and prevents unintended edits.agents/agent-riza/package.json (1)
29-36: Review duplicate Anthropic SDK dependencies.Both
@ai-sdk/anthropicand@anthropic-ai/sdkare listed. Confirm if you need both or if one can be removed to reduce bundle size.#!/bin/bash # Check where each Anthropic SDK package is used rg -n "@ai-sdk/anthropic" -A2 rg -n "@anthropic-ai/sdk" -A2agents/agent-riza/agentuity.yaml (1)
30-33: Verify non-standard Node flags.Flags like
--env-file-if-existsand some security flags may not be recognized bynodedirectly. Confirm these are handled by the Agentuity loader or switch to a supported approach (e.g., usingdotenv).agents/agent-riza/index.ts (1)
27-41: Nice developer UX 👍Proactively warning when
AGENTUITY_URLis missing and tailoring advice for Bun vs Node is a great touch.agents/agent-riza/src/agents/agent-riza/index.ts (2)
83-84: Return type already provided by helper – no issuesStraightforward hand-off to
resp.text(result).
21-23: Here’s a quick dive into the file and any existing ANTHROPIC_API_KEY usage:#!/bin/bash set -e echo "=== index.ts (first 50 lines) ===" sed -n '1,50p' agents/agent-riza/src/agents/agent-riza/index.ts echo echo "=== References to ANTHROPIC_API_KEY ===" rg "ANTHROPIC_API_KEY" -n .agents/agent-riza/.cursor/rules/sdk.mdc (1)
90-96: Great to see best-practice notes includedThe guidance is concise and useful for new contributors.
| indent_style = tab | ||
| indent_size = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation style with biome.json.
.editorconfig enforces tabs, whereas biome.json uses spaces (indentStyle: space). Align both configurations to a single indentation strategy to avoid formatting conflicts.
🤖 Prompt for AI Agents
In agents/agent-riza/.editorconfig at lines 7 to 8, the indentation style is set
to tabs, which conflicts with the spaces indentation style defined in
biome.json. To fix this, change the indent_style value from "tab" to "space" and
adjust indent_size accordingly to match biome.json's configuration, ensuring
consistent indentation across both files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be good to have devin fix in template repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jhaynie You're absolutely right - fixing this at the template level would prevent this inconsistency from appearing in all future agent projects. It's much better to address the root cause rather than fixing it project by project.
Would you like me to create an issue to track getting this EditorConfig/Biome indentation alignment fixed in the template repository? I can include the specific details about the conflict (tabs vs spaces) and reference this PR for context.
Also, just to make sure I target the right repository - is this referring to an internal Agentuity agent template repo, or should this issue be opened elsewhere?
| logs | ||
| _.log | ||
| report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in log file ignore pattern.
The entry _.log only matches filenames starting with an underscore. It should be *.log to ignore all .log files.
Apply this diff:
- logs
- _.log
+ logs
+ *.log📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logs | |
| _.log | |
| report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | |
| logs | |
| *.log | |
| report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json |
🤖 Prompt for AI Agents
In agents/agent-riza/.gitignore around lines 13 to 15, the pattern `_.log`
incorrectly matches only files starting with an underscore. Replace `_.log` with
`*.log` to correctly ignore all files ending with the `.log` extension.
| "scripts": { | ||
| "build": "agentuity build", | ||
| "dev": "agentuity dev", | ||
| "format": "biome format --write .", | ||
| "lint": "biome lint .", | ||
| "prestart": "agentuity bundle", | ||
| "start": "node --env-file .env --no-deprecation .agentuity/index.js", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Implement a real test script or remove placeholder.
The test script currently exits with an error. Integrate a testing framework (e.g., Jest) or update the command to prevent confusion for contributors.
🤖 Prompt for AI Agents
In agents/agent-riza/package.json between lines 7 and 15, the "test" script is a
placeholder that exits with an error, which can confuse contributors. To fix
this, either integrate a testing framework like Jest and update the "test"
script to run the tests, or remove the "test" script entirely if no tests are
planned. This will ensure the test command is meaningful or absent to avoid
misleading users.
| "name": "agent-riza2", | ||
| "description": "", | ||
| "version": "0.0.1", | ||
| "main": "index.js", | ||
| "type": "module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mismatched package name vs. project naming.
The "name": "agent-riza2" doesn’t align with the directory (agent-riza) or the agent name in agentuity.yaml (agent-riza). Unify the package name to avoid confusion in imports and deployment.
🤖 Prompt for AI Agents
In agents/agent-riza/package.json lines 2 to 6, the package name is set to
"agent-riza2" which does not match the directory name "agent-riza" or the agent
name in agentuity.yaml. Change the "name" field in package.json to "agent-riza"
to ensure consistency across the project and avoid confusion during imports and
deployment.
| 4. Sign up for Riza and create an API key. Then you can put it in your `.env` file (match formatting in `.env.example`.) | ||
| 4. Run `agentuity dev` to start the local development server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct duplicate step numbering.
Steps 4 and 4 under "Getting Started" should be renumbered sequentially to maintain clarity.
🤖 Prompt for AI Agents
In agents/agent-riza/README.md around lines 37 to 38, the steps under "Getting
Started" have duplicate numbering for step 4. Renumber the second step 4 to step
5 to ensure the steps are sequential and clear.
| agents: | ||
| - # The ID of the Agent which is automatically generated | ||
| id: agent_c570eb8eb5ba873fee56087b4498fa51 | ||
| # The name of the Agent which is editable | ||
| name: agent-riza |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Inconsistent agent naming.
The agent is listed as agent-riza here while the project is named agent-riza2. Ensure naming is consistent across package.json, agentuity.yaml, and directory structure to avoid deployment conflicts.
🤖 Prompt for AI Agents
In agents/agent-riza/agentuity.yaml around lines 65 to 69, the agent name is set
as "agent-riza" which is inconsistent with the project name "agent-riza2".
Update the agent name in this file to "agent-riza2" to match the project name
and ensure consistency with package.json and the directory structure to prevent
deployment conflicts.
| - node_modules/** | ||
| - dist/** | ||
| - src/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundler ignore pattern excludes source directory.
The ignore list includes src/**, which would omit your agent code from the bundle. Remove or narrow this pattern so src/agents is not ignored.
🤖 Prompt for AI Agents
In agents/agent-riza/agentuity.yaml around lines 61 to 63, the ignore pattern
includes 'src/**', which excludes the entire source directory including your
agent code from the bundle. Modify the ignore list to remove 'src/**' or replace
it with a more specific pattern that excludes unwanted files but keeps
'src/agents' included, ensuring your agent code is bundled correctly.
| for (let contentBlock of msg.content) { | ||
| if (contentBlock.type === "text") { | ||
| result += contentBlock.text; | ||
| } | ||
| // If Claude wants to use a tool (in this case the only tool is 'code') we can execute the code it wants to through Riza. | ||
| if (contentBlock.type === "tool_use") { | ||
| let input = contentBlock.input as CommandExecParams; | ||
| result += `\n\n### Executing ${input.language} Program\n\`\`\`${input.language}\n${input.code}\n\`\`\`\n`; | ||
|
|
||
| // Use Riza's command execution API to run code safely. | ||
| let execResult = await riza.command.exec(input); | ||
|
|
||
| result += "\n#### Program Output\n```\n"; | ||
|
|
||
| // Handle Riza execution results and format for Agentuity response | ||
| if (execResult.exit_code !== 0) { | ||
| result += `Error (Exit Code ${execResult.exit_code}):\n${execResult.stderr}`; | ||
| } else { | ||
| result += execResult.stdout; | ||
| } | ||
| result += "\n```\n"; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Execution path needs stronger error handling & type safety
execResult.exit_codemay actually beexitCodein the Riza SDK (double-check).- If
riza.command.exec()throws (network failure, quota, etc.) the whole request 500s. Wrap intry/catchand surface a formatted error back to the user instead.
- let execResult = await riza.command.exec(input);
+ let execResult;
+ try {
+ execResult = await riza.command.exec(input);
+ } catch (err: unknown) {
+ result += "\n#### Program Error\n```\n" + String(err) + "\n```\n";
+ continue;
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| for (let contentBlock of msg.content) { | |
| if (contentBlock.type === "text") { | |
| result += contentBlock.text; | |
| } | |
| // If Claude wants to use a tool (in this case the only tool is 'code') we can execute the code it wants to through Riza. | |
| if (contentBlock.type === "tool_use") { | |
| let input = contentBlock.input as CommandExecParams; | |
| result += `\n\n### Executing ${input.language} Program\n\`\`\`${input.language}\n${input.code}\n\`\`\`\n`; | |
| // Use Riza's command execution API to run code safely. | |
| let execResult = await riza.command.exec(input); | |
| result += "\n#### Program Output\n```\n"; | |
| // Handle Riza execution results and format for Agentuity response | |
| if (execResult.exit_code !== 0) { | |
| result += `Error (Exit Code ${execResult.exit_code}):\n${execResult.stderr}`; | |
| } else { | |
| result += execResult.stdout; | |
| } | |
| result += "\n```\n"; | |
| } | |
| } | |
| for (let contentBlock of msg.content) { | |
| if (contentBlock.type === "text") { | |
| result += contentBlock.text; | |
| } | |
| // If Claude wants to use a tool (in this case the only tool is 'code') we can execute the code it wants to through Riza. | |
| if (contentBlock.type === "tool_use") { | |
| let input = contentBlock.input as CommandExecParams; | |
| result += `\n\n### Executing ${input.language} Program\n\`\`\`${input.language}\n${input.code}\n\`\`\`\n`; | |
| // Use Riza's command execution API to run code safely. | |
| - let execResult = await riza.command.exec(input); | |
| + let execResult; | |
| + try { | |
| + execResult = await riza.command.exec(input); | |
| + } catch (err: unknown) { | |
| + result += "\n#### Program Error\n |
🤖 Prompt for AI Agents
In agents/agent-riza/src/agents/agent-riza/index.ts between lines 59 and 81, the
code calling riza.command.exec lacks error handling and may use an incorrect
property name for the exit code. Verify if the correct property is exitCode
instead of exit_code. Wrap the call to riza.command.exec in a try/catch block to
handle exceptions like network failures or quota issues, and in the catch block,
append a formatted error message to the result string to inform the user instead
of letting the request fail with a 500 error. This will improve robustness and
user feedback.
Summary by CodeRabbit
New Features
Documentation
Chores