-
Notifications
You must be signed in to change notification settings - Fork 5
Add OpenAI framework examples with deterministicStory, translation, a… #15
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
Conversation
WalkthroughThis change introduces a new Agentuity-based Python project, "from-oai". It adds project configuration files, documentation, and a set of agent implementations for deterministic story generation, translation, and tutoring. The commit includes agent workflow code, environment setup, development and deployment configuration, and best practice guidelines for building and running AI agents using the Agentuity platform. Changes
Sequence Diagram(s)Deterministic Story Agent WorkflowsequenceDiagram
participant User
participant MainAgent as deterministicStoryAgent.run
participant OutlineAgent
participant CheckerAgent
participant StoryAgent
User->>MainAgent: Submit story prompt
MainAgent->>OutlineAgent: Generate story outline
OutlineAgent-->>MainAgent: Outline
MainAgent->>CheckerAgent: Check outline quality & genre
CheckerAgent-->>MainAgent: Quality check result
alt Outline rejected
MainAgent-->>User: Return rejection with reasons
else Outline accepted
MainAgent->>StoryAgent: Write story from outline
StoryAgent-->>MainAgent: Story text
MainAgent-->>User: Return outline, story, and check details
end
Translation Agent WorkflowsequenceDiagram
participant User
participant MainAgent as translationAgent.run
participant Orchestrator
participant SpanishAgent
participant FrenchAgent
participant ItalianAgent
participant Synthesizer
User->>MainAgent: Submit message to translate
MainAgent->>Orchestrator: Orchestrate translation
Orchestrator->>SpanishAgent: Translate to Spanish
Orchestrator->>FrenchAgent: Translate to French
Orchestrator->>ItalianAgent: Translate to Italian
SpanishAgent-->>Orchestrator: Spanish translation
FrenchAgent-->>Orchestrator: French translation
ItalianAgent-->>Orchestrator: Italian translation
Orchestrator-->>MainAgent: Collected translations
MainAgent->>Synthesizer: Synthesize and correct translations
Synthesizer-->>MainAgent: Final combined translation
MainAgent-->>User: Return synthesized translations
Tutor Agent WorkflowsequenceDiagram
participant User
participant MainAgent as tutorAgent.run
participant GuardrailAgent
participant TriageAgent
participant MathTutor
participant HistoryTutor
User->>MainAgent: Submit question
MainAgent->>TriageAgent: Triage question with guardrail
TriageAgent->>GuardrailAgent: Check if homework
GuardrailAgent-->>TriageAgent: Homework check result
alt Math question
TriageAgent->>MathTutor: Answer math question
MathTutor-->>TriageAgent: Math answer
else History question
TriageAgent->>HistoryTutor: Answer history question
HistoryTutor-->>TriageAgent: History answer
end
TriageAgent-->>MainAgent: Final answer
MainAgent-->>User: Return answer or error message
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🪧 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: 7
🧹 Nitpick comments (13)
frameworks/openai/from-oai/.editorconfig (1)
6-12: Review indentation and whitespace rules.
indent_style = tabwithindent_size = 2will render tabs as two spaces; please verify this aligns with your Python formatter (e.g., Black defaults to 4-space indents).- Consider setting
insert_final_newline = trueto ensure files end with a newline (a common convention that prevents diff noise).- You may also want
trim_trailing_whitespace = truefor code files to avoid accidental trailing spaces—overrides can be added per file type if markdown requires trailing spaces.frameworks/openai/from-oai/main.py (3)
1-2: Add a module-level docstring.
Include a brief top-of-file docstring to explain the script’s purpose and improve documentation.+""" +Example entry point for the 'from-oai' agent framework. +""" + def main():
1-3: Add type hints and a function docstring.
Specify-> Nonefor the return type and document whatmain()does to aid static analysis and readability.-def main(): +def main() -> None: + """ + Prints a greeting message for the 'from-oai' example. + """ print("Hello from from-oai!")
5-6: Enforce PEP8 blank-line conventions.
PEP8 recommends two blank lines before top-level code blocks like theif __name__ == "__main__"guard, and ensure a newline at EOF.frameworks/openai/from-oai/.python-version (1)
1-2: Ensure Python version consistency & remove trailing blank line
The.python-versioncorrectly pins3.11, which satisfies>=3.10,<3.13inpyproject.toml. Consider removing the empty second line for cleanliness and to avoid potential parsing issues with some tools.frameworks/openai/from-oai/pyproject.toml (1)
1-9: Enrich project metadata
You have the minimal[project]section and dependencies in place. For a more complete PyPI package, consider adding:
description(non-empty)readmeentry pointing toREADME.mdlicensefieldauthorsormaintainers- Optional
keywords,classifiers
This will improve the package’s discoverability and compliance.frameworks/openai/from-oai/README.md (1)
68-74: Specify language for the file-tree code block
Markdown lint flags the fenced code block for the project structure as missing a language. Add e.g.textafter the backticks to satisfy linters and improve rendering.Apply this diff:
-``` +```text🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
68-68: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
frameworks/openai/from-oai/server.py (1)
21-27: Mismatch between severity (WARN) and ANSI colour (RED)Warnings are printed in red (error colour), which can startle operators and generate false alarms.
Consider either usinglogging.warning(which many log collectors map to yellow) or changing the escape sequence to\033[33m(yellow) if you really want colouredstdout.frameworks/openai/from-oai/my_agents/translationAgent/agent.py (1)
1-3: Remove unusedasyncioimportStatic analysis (
ruff F401) flags this as unused.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
frameworks/openai/from-oai/.gitignore (1)
131-139: Consider committing.env.example
.envfiles are correctly ignored, but providing a redacted.env.examplecommitted to the repo documents required variables (AGENTUITY_API_KEY,AGENTUITY_URL, …) and helps onboarding.frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
1-1: Remove unused import to satisfy linter and reduce clutter
asynciois imported but never used. Ruff already flags this (F401). Removing it keeps the file clean and avoids future CI failures.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
frameworks/openai/from-oai/agentuity.yaml (1)
60-69: Add descriptivename/descriptionfields for better dashboard UXCurrently each agent only provides an internal identifier; dashboards and logs will show these raw IDs. Supplying user-friendly
nameanddescriptionfields improves discoverability.agents: - id: agent_6b3a1c62caf05f6dac7a50b50ef635cb name: tutorAgent description: "Answers user questions across subjects with specialised sub-agents" ...frameworks/openai/from-oai/.cursor/rules/sdk.mdc (1)
3-4: Glob pattern does not match project layoutThe project stores agents in
my_agents/**, but the rules file targetsagents/**/*.py. This prevents Cursor from surfacing the SDK hints inside your agents.-globs: "agents/**/*.py" +globs: "my_agents/**/*.py"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
frameworks/openai/from-oai/uv.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
frameworks/openai/from-oai/.cursor/rules/agent.mdc(1 hunks)frameworks/openai/from-oai/.cursor/rules/agentuity.mdc(1 hunks)frameworks/openai/from-oai/.cursor/rules/sdk.mdc(1 hunks)frameworks/openai/from-oai/.editorconfig(1 hunks)frameworks/openai/from-oai/.gitignore(1 hunks)frameworks/openai/from-oai/.python-version(1 hunks)frameworks/openai/from-oai/README.md(1 hunks)frameworks/openai/from-oai/agentuity.yaml(1 hunks)frameworks/openai/from-oai/main.py(1 hunks)frameworks/openai/from-oai/my_agents/__init__.py(1 hunks)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/translationAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/tutorAgent/__init__.py(1 hunks)frameworks/openai/from-oai/my_agents/tutorAgent/agent.py(1 hunks)frameworks/openai/from-oai/pyproject.toml(1 hunks)frameworks/openai/from-oai/server.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
run(30-84)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (1)
run(54-77)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
run(30-84)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)frameworks/openai/from-oai/my_agents/translationAgent/agent.py (1)
run(54-77)
🪛 markdownlint-cli2 (0.17.2)
frameworks/openai/from-oai/README.md
68-68: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 Ruff (0.11.9)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
🔇 Additional comments (7)
frameworks/openai/from-oai/my_agents/__init__.py (1)
1-1: Package initializer is correctly added.
Including an__init__.py(even if empty) ensuresmy_agentsis recognized as a Python package.frameworks/openai/from-oai/my_agents/tutorAgent/__init__.py (1)
1-1: Package initialization marker is correct.
The empty__init__.pywith a clarifying comment appropriately designates this directory as a Python package for thetutorAgentmodule.frameworks/openai/from-oai/.editorconfig (1)
1-4: Appropriate root declaration and header.
The header comment androot = truedeclaration correctly identify this as the primary EditorConfig file for thefrom-oaiproject.frameworks/openai/from-oai/main.py (1)
1-7: Basic example entry point is correct.
Themain()function prints a greeting and the__main__guard invokes it properly, serving as a minimal standalone example.frameworks/openai/from-oai/.cursor/rules/agentuity.mdc (2)
1-5: Agentuity rule file configuration is correct
The front-matter targetsagentuity.yamlandalwaysApply: trueensures the guidelines are enforced consistently.
7-10: Clarify rule usage
The description clearly instructs not to suggest edits toagentuity.yaml. No changes needed here.frameworks/openai/from-oai/.cursor/rules/agent.mdc (1)
7-14: Agent development guidelines are sound
The asyncrunsignature, import recommendations, and logging best practices align with the SDK’s requirements.
| --- | ||
| description: Guidelines for writing Agentuity AI Agents in Python | ||
| globs: "agents/**/*.py" | ||
| alwaysApply: true | ||
| --- | ||
|
|
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.
Verify glob pattern matches your directory structure
The rule’s globs: "agents/**/*.py" assumes an agents/ directory, but elsewhere (e.g., summary) the code lives under my_agents/. Please confirm the actual directory name and update this glob so the rule applies correctly.
🤖 Prompt for AI Agents
In frameworks/openai/from-oai/.cursor/rules/agent.mdc at lines 1 to 6, the glob
pattern "agents/**/*.py" does not match the actual directory structure, which
uses "my_agents/". Update the glob pattern to "my_agents/**/*.py" or the correct
directory name to ensure the rule applies to the intended files.
| print( | ||
| "\033[31m[ERROR] AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. This should have been set automatically by the Agentuity CLI or picked up from the .env file.\033[0m" | ||
| ) | ||
| if os.environ.get("_", "").endswith("uv") and os.path.exists(".env"): | ||
| print( | ||
| "\033[31m[ERROR] Re-run the command with `uv run --env-file .env server.py`\033[0m" | ||
| ) | ||
| sys.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
Prefer logging over print for fatal configuration errors
print() pushes the message to stdout, which is inconsistent with the rest of the file that uses the logging module.
Switching to logging.error (or at least writing to sys.stderr) keeps all diagnostic output on the same channel and makes it easier to capture/ship logs in production.
- print(
- "\033[31m[ERROR] AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. This should have been set automatically by the Agentuity CLI or picked up from the .env file.\033[0m"
- )
+ logging.error(
+ "AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. "
+ "This should have been set automatically by the Agentuity CLI "
+ "or picked up from the .env file."
+ )(Apply the same pattern for the follow-up hint about uv.)
This also eliminates the hard-coded ANSI colour escape, letting the log transport decide about colouring.
📝 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.
| print( | |
| "\033[31m[ERROR] AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. This should have been set automatically by the Agentuity CLI or picked up from the .env file.\033[0m" | |
| ) | |
| if os.environ.get("_", "").endswith("uv") and os.path.exists(".env"): | |
| print( | |
| "\033[31m[ERROR] Re-run the command with `uv run --env-file .env server.py`\033[0m" | |
| ) | |
| sys.exit(1) | |
| logging.error( | |
| "AGENTUITY_API_KEY or AGENTUITY_SDK_KEY is not set. " | |
| "This should have been set automatically by the Agentuity CLI " | |
| "or picked up from the .env file." | |
| ) | |
| if os.environ.get("_", "").endswith("uv") and os.path.exists(".env"): | |
| print( | |
| "\033[31m[ERROR] Re-run the command with `uv run --env-file .env server.py`\033[0m" | |
| ) | |
| sys.exit(1) |
🤖 Prompt for AI Agents
In frameworks/openai/from-oai/server.py around lines 11 to 18, replace the print
statements used for error messages with logging.error calls to maintain
consistency with the rest of the file and ensure error messages go to the proper
logging channel. Remove the hard-coded ANSI color codes from the messages so
that log formatting and coloring can be handled by the logging configuration or
environment. This applies to both the main error message and the follow-up hint
about re-running the command with uv.
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
Outdated
Show resolved
Hide resolved
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: 4
♻️ Duplicate comments (1)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
30-92: 🛠️ Refactor suggestionAdd a top-level
try/exceptto prevent unhandled 500s
This was highlighted in a previous review and remains unresolved.Unhandled exceptions from any
Runner.runcall will bubble up and produce an opaque 500 response. Wrap the workflow intry/except, log the stack trace, and return a user-friendly JSON error similar to the Tutor and Translation agents.
🧹 Nitpick comments (3)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
1-3: Remove unusedasyncioimport
asyncioisn’t referenced in this module and is flagged by Ruff (F401).
Deleting it avoids unnecessary namespace clutter.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
59-60: Prefer parameterised logging over f-stringsUsing
"%s"placeholders defers string interpolation until the log level is enabled and avoids creating extra string objects.- context.logger.info(f"Processing translation request: {user_message}") + context.logger.info("Processing translation request: %s", user_message)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
1-3: Remove unusedasyncioimportThe module doesn’t reference
asyncio; drop the import to satisfy Ruff (F401).-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frameworks/openai/from-oai/.cursor/rules/agent.mdc(1 hunks)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/translationAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/tutorAgent/agent.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frameworks/openai/from-oai/.cursor/rules/agent.mdc
🧰 Additional context used
🧬 Code Graph Analysis (2)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
run(30-92)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (1)
run(54-79)frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)
🪛 Ruff (0.11.9)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
Outdated
Show resolved
Hide resolved
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: 0
🧹 Nitpick comments (3)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
1-1: Remove unused import.The
asynciomodule is imported but never used in this file.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
1-1: Remove unused import.The
asyncioimport is not used anywhere in the code and should be removed.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
66-70: Minor optimization opportunity for logging loop.The current logging loop processes all items but only logs
MessageOutputIteminstances. Consider adding a type check early to avoid unnecessary processing.# Log intermediate steps using Agentuity's logger for item in orchestrator_result.new_items: if isinstance(item, MessageOutputItem): text = ItemHelpers.text_message_output(item) if text: context.logger.info(f"Translation step: {text}")Could be optimized to:
# Log intermediate steps using Agentuity's logger for item in orchestrator_result.new_items: if isinstance(item, MessageOutputItem): text = ItemHelpers.text_message_output(item) if text: context.logger.info("Translation step: %s", text)Note: Using
%sformatting is generally preferred over f-strings in logging for performance reasons.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/translationAgent/agent.py(1 hunks)frameworks/openai/from-oai/my_agents/tutorAgent/agent.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frameworks/openai/from-oai/my_agents/tutorAgent/agent.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (1)
run(30-100)
🪛 Ruff (0.11.9)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
frameworks/openai/from-oai/my_agents/translationAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
🔇 Additional comments (5)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (3)
9-28: Agent definitions look well-structured.The agent definitions follow good practices with clear instructions and appropriate output types. The Pydantic model
OutlineCheckerOutputprovides type safety for the outline checker results.
30-36: Function signature and initial setup are correct.The async function signature follows Agentuity conventions correctly, and the input extraction and initial logging are properly implemented.
37-100: Excellent implementation of the deterministic story workflow.The implementation successfully addresses all the concerns from previous reviews:
✅ Error handling: Comprehensive try/catch block with proper logging
✅ Context propagation: AllRunner.runcalls includecontext=context
✅ Type checking: Explicit validation instead of assert statements
✅ Workflow control: Clear gates for quality and genre validation
✅ Response consistency: Structured JSON responses with appropriate status codesThe workflow logic is sound and follows a clear three-stage process: outline generation → quality/genre validation → story writing, with appropriate early exits for rejected outlines.
frameworks/openai/from-oai/my_agents/translationAgent/agent.py (2)
8-52: Well-structured agent definitions.The agent definitions are well-organized with clear roles:
- Individual translation agents for Spanish, French, and Italian
- Orchestrator agent that delegates to translation tools without doing translation itself
- Synthesizer agent for post-processing
The orchestrator's instructions properly emphasize using tools rather than translating directly, which is a good design pattern.
54-79: Robust implementation with proper error handling.The run function implementation addresses all the issues from previous reviews:
- ✅ Error handling with try/catch block
- ✅ Context forwarding to
Runner.runcalls- ✅ Structured logging using
context.logger- ✅ User-friendly error messages
The workflow properly traces execution and logs intermediate steps for observability.
rblalock
left a comment
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.
Very nice! Made a comment on the README .
| <br /> | ||
| </div> | ||
|
|
||
| # 🤖 Python Agent Project |
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.
At the top here, mention that these examples are from open ai agent framework. link to their docs, mention a brief sentence about how easy it is to take open ai agent framework and use it in agentuity. a code sample that shows the run handler and then invoking one of their agents is good too.
If there are some screenshots of it working (console, logs, or stuff in dev mode, even better).
| from agentuity import AgentRequest, AgentResponse, AgentContext | ||
| from pydantic import BaseModel | ||
|
|
||
| # Your existing OpenAI Agents SDK imports and setup |
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.
Are these AI generated comments? They seem like it. Remove please
| input_prompt = await request.data.text() | ||
|
|
||
| # Use Agentuity's logging | ||
| context.logger.info(f"Starting story generation for prompt: {input_prompt}") |
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.
I like how you add comments liks this describing how it works and what its for.
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: 0
♻️ Duplicate comments (1)
frameworks/openai/from-oai/README.md (1)
17-37: Include a screenshot or sample output
Visual examples (console logs, dev‐mode screenshots, or API responses) can help users quickly grasp what the integration looks like in practice.
🧹 Nitpick comments (8)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (5)
1-1: Remove unused import.The
asyncioimport is not used anywhere in this file.-import asyncio🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
🪛 Pylint (3.3.7)
[convention] 1-1: Trailing whitespace
(C0303)
[convention] 1-1: Missing module docstring
(C0114)
[warning] 1-1: Unused import asyncio
(W0611)
1-5: Fix import order and formatting issues.The imports should follow PEP 8 conventions with third-party imports before first-party imports, and there are trailing whitespace issues throughout the file.
-import asyncio -from agentuity import AgentRequest, AgentResponse, AgentContext -from pydantic import BaseModel - -from agents import Agent, Runner, trace +from pydantic import BaseModel + +from agentuity import AgentRequest, AgentResponse, AgentContext +from agents import Agent, Runner, trace🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
🪛 Pylint (3.3.7)
[convention] 1-1: Trailing whitespace
(C0303)
[convention] 2-2: Trailing whitespace
(C0303)
[convention] 3-3: Trailing whitespace
(C0303)
[convention] 4-4: Trailing whitespace
(C0303)
[convention] 5-5: Trailing whitespace
(C0303)
[convention] 1-1: Missing module docstring
(C0114)
[error] 2-2: Unable to import 'agentuity'
(E0401)
[error] 3-3: Unable to import 'pydantic'
(E0401)
[error] 5-5: Unable to import 'agents'
(E0401)
[convention] 3-3: third party import "pydantic.BaseModel" should be placed before first party import "agentuity.AgentRequest"
(C0411)
[warning] 1-1: Unused import asyncio
(W0611)
34-34: Use format strings consistently with logging best practices.While f-strings work, the logging module recommends using format arguments for better performance and consistency with other logging calls in the file.
- context.logger.info(f"Starting story generation for prompt: {input_prompt}") + context.logger.info("Starting story generation for prompt: %s", input_prompt)🧰 Tools
🪛 Pylint (3.3.7)
[convention] 34-34: Trailing whitespace
(C0303)
51-59: Consider adding more specific error details for debugging.The type checking is good defensive programming, but could provide more context about what was expected vs received.
if not isinstance(outline_checker_result.final_output, OutlineCheckerOutput): context.logger.error( - "Unexpected output type from outline_checker_agent: %s", - type(outline_checker_result.final_output) + "Unexpected output type from outline_checker_agent. Expected: %s, Got: %s", + OutlineCheckerOutput.__name__, + type(outline_checker_result.final_output).__name__ ) return response.json({ "status": "error", - "reason": "Invalid outline-checker output" + "reason": f"Invalid outline-checker output: expected {OutlineCheckerOutput.__name__}" })
1-99: Address formatting issues flagged by static analysis.The file has extensive trailing whitespace on most lines and is missing a final newline. These should be cleaned up for code quality.
Consider running a formatter like
blackor manually removing trailing whitespace and adding a final newline to address the numerous C0303 and C0304 pylint warnings.🧰 Tools
🪛 Ruff (0.11.9)
1-1:
asyncioimported but unusedRemove unused import:
asyncio(F401)
🪛 Pylint (3.3.7)
[convention] 1-1: Trailing whitespace
(C0303)
[convention] 2-2: Trailing whitespace
(C0303)
[convention] 3-3: Trailing whitespace
(C0303)
[convention] 4-4: Trailing whitespace
(C0303)
[convention] 5-5: Trailing whitespace
(C0303)
[convention] 6-6: Trailing whitespace
(C0303)
[convention] 7-7: Trailing whitespace
(C0303)
[convention] 8-8: Trailing whitespace
(C0303)
[convention] 9-9: Trailing whitespace
(C0303)
[convention] 10-10: Trailing whitespace
(C0303)
[convention] 11-11: Trailing whitespace
(C0303)
[convention] 12-12: Trailing whitespace
(C0303)
[convention] 13-13: Trailing whitespace
(C0303)
[convention] 14-14: Trailing whitespace
(C0303)
[convention] 15-15: Trailing whitespace
(C0303)
[convention] 16-16: Trailing whitespace
(C0303)
[convention] 17-17: Trailing whitespace
(C0303)
[convention] 18-18: Trailing whitespace
(C0303)
[convention] 19-19: Trailing whitespace
(C0303)
[convention] 19-19: Line too long (112/100)
(C0301)
[convention] 20-20: Trailing whitespace
(C0303)
[convention] 21-21: Trailing whitespace
(C0303)
[convention] 22-22: Trailing whitespace
(C0303)
[convention] 23-23: Trailing whitespace
(C0303)
[convention] 24-24: Trailing whitespace
(C0303)
[convention] 25-25: Trailing whitespace
(C0303)
[convention] 26-26: Trailing whitespace
(C0303)
[convention] 27-27: Trailing whitespace
(C0303)
[convention] 28-28: Trailing whitespace
(C0303)
[convention] 29-29: Trailing whitespace
(C0303)
[convention] 30-30: Trailing whitespace
(C0303)
[convention] 31-31: Trailing whitespace
(C0303)
[convention] 32-32: Trailing whitespace
(C0303)
[convention] 33-33: Trailing whitespace
(C0303)
[convention] 34-34: Trailing whitespace
(C0303)
[convention] 35-35: Trailing whitespace
(C0303)
[convention] 37-37: Trailing whitespace
(C0303)
[convention] 38-38: Trailing whitespace
(C0303)
[convention] 39-39: Trailing whitespace
(C0303)
[convention] 40-40: Trailing whitespace
(C0303)
[convention] 41-41: Trailing whitespace
(C0303)
[convention] 42-42: Trailing whitespace
(C0303)
[convention] 43-43: Trailing whitespace
(C0303)
[convention] 44-44: Trailing whitespace
(C0303)
[convention] 45-45: Trailing whitespace
(C0303)
[convention] 46-46: Trailing whitespace
(C0303)
[convention] 48-48: Trailing whitespace
(C0303)
[convention] 49-49: Trailing whitespace
(C0303)
[convention] 50-50: Trailing whitespace
(C0303)
[convention] 60-60: Trailing whitespace
(C0303)
[convention] 61-61: Trailing whitespace
(C0303)
[convention] 62-62: Trailing whitespace
(C0303)
[convention] 63-63: Trailing whitespace
(C0303)
[convention] 67-67: Trailing whitespace
(C0303)
[convention] 68-68: Trailing whitespace
(C0303)
[convention] 69-69: Trailing whitespace
(C0303)
[convention] 70-70: Trailing whitespace
(C0303)
[convention] 71-71: Trailing whitespace
(C0303)
[convention] 75-75: Trailing whitespace
(C0303)
[convention] 76-76: Trailing whitespace
(C0303)
[convention] 77-77: Trailing whitespace
(C0303)
[convention] 77-77: Line too long (107/100)
(C0301)
[convention] 78-78: Trailing whitespace
(C0303)
[convention] 79-79: Trailing whitespace
(C0303)
[convention] 80-80: Trailing whitespace
(C0303)
[convention] 80-80: Line too long (102/100)
(C0301)
[convention] 81-81: Trailing whitespace
(C0303)
[convention] 82-82: Trailing whitespace
(C0303)
[convention] 83-83: Trailing whitespace
(C0303)
[convention] 84-84: Trailing whitespace
(C0303)
[convention] 85-85: Trailing whitespace
(C0303)
[convention] 92-92: Trailing whitespace
(C0303)
[convention] 94-94: Trailing whitespace
(C0303)
[convention] 99-99: Final newline missing
(C0304)
[convention] 1-1: Missing module docstring
(C0114)
[error] 2-2: Unable to import 'agentuity'
(E0401)
[error] 3-3: Unable to import 'pydantic'
(E0401)
[error] 5-5: Unable to import 'agents'
(E0401)
[convention] 13-13: Missing class docstring
(C0115)
[refactor] 13-13: Too few public methods (0/2)
(R0903)
[convention] 29-29: Missing function or method docstring
(C0116)
[warning] 94-94: Catching too general exception Exception
(W0718)
[convention] 3-3: third party import "pydantic.BaseModel" should be placed before first party import "agentuity.AgentRequest"
(C0411)
[warning] 1-1: Unused import asyncio
(W0611)
frameworks/openai/from-oai/README.md (3)
98-104: Specify the language for the code fence
The directory tree code block is missing a language specifier, which triggers markdownlint (MD040). Adding a language (e.g.,text) will satisfy the lint rule and improve readability.Apply this diff:
- ``` + ```text🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
98-98: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
98-104: Update project structure to include all repo files
Your tree currently lists onlyagents/,.venv/,pyproject.toml,server.py, andagentuity.yaml. The repository also contains.python-version,.gitignore, and.editorconfig(and potentially.cursor/docs) that contributors will expect to see. Consider adding them for completeness.Example diff:
-├── pyproject.toml # Project dependencies and metadata -├── server.py # Server entry point -└── agentuity.yaml # Agentuity project configuration +├── pyproject.toml # Project dependencies and metadata +├── .python-version # Python version specification +├── .gitignore # Files to ignore in VCS +├── .editorconfig # Editor configuration rules +├── server.py # Server entry point +└── agentuity.yaml # Agentuity project configuration🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
98-98: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
128-132: Link to detailed.cursor/rulesdocumentation
The repo includes.cursor/rules/agent.mdc,sdk.mdc, andagentuity.mdcwith API signatures and best practices. Adding a reference in the Documentation section will guide users to those in-depth guides.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frameworks/openai/from-oai/README.md(1 hunks)frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (2)
frameworks/openai/from-oai/my_agents/tutorAgent/agent.py (1)
run(46-65)frameworks/openai/from-oai/my_agents/translationAgent/agent.py (1)
run(54-79)
🪛 markdownlint-cli2 (0.17.2)
frameworks/openai/from-oai/README.md
98-98: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
🪛 Ruff (0.11.9)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
1-1: asyncio imported but unused
Remove unused import: asyncio
(F401)
🪛 Pylint (3.3.7)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py
[convention] 1-1: Trailing whitespace
(C0303)
[convention] 2-2: Trailing whitespace
(C0303)
[convention] 3-3: Trailing whitespace
(C0303)
[convention] 4-4: Trailing whitespace
(C0303)
[convention] 5-5: Trailing whitespace
(C0303)
[convention] 6-6: Trailing whitespace
(C0303)
[convention] 7-7: Trailing whitespace
(C0303)
[convention] 8-8: Trailing whitespace
(C0303)
[convention] 9-9: Trailing whitespace
(C0303)
[convention] 10-10: Trailing whitespace
(C0303)
[convention] 11-11: Trailing whitespace
(C0303)
[convention] 12-12: Trailing whitespace
(C0303)
[convention] 13-13: Trailing whitespace
(C0303)
[convention] 14-14: Trailing whitespace
(C0303)
[convention] 15-15: Trailing whitespace
(C0303)
[convention] 16-16: Trailing whitespace
(C0303)
[convention] 17-17: Trailing whitespace
(C0303)
[convention] 18-18: Trailing whitespace
(C0303)
[convention] 19-19: Trailing whitespace
(C0303)
[convention] 19-19: Line too long (112/100)
(C0301)
[convention] 20-20: Trailing whitespace
(C0303)
[convention] 21-21: Trailing whitespace
(C0303)
[convention] 22-22: Trailing whitespace
(C0303)
[convention] 23-23: Trailing whitespace
(C0303)
[convention] 24-24: Trailing whitespace
(C0303)
[convention] 25-25: Trailing whitespace
(C0303)
[convention] 26-26: Trailing whitespace
(C0303)
[convention] 27-27: Trailing whitespace
(C0303)
[convention] 28-28: Trailing whitespace
(C0303)
[convention] 29-29: Trailing whitespace
(C0303)
[convention] 30-30: Trailing whitespace
(C0303)
[convention] 31-31: Trailing whitespace
(C0303)
[convention] 32-32: Trailing whitespace
(C0303)
[convention] 33-33: Trailing whitespace
(C0303)
[convention] 34-34: Trailing whitespace
(C0303)
[convention] 35-35: Trailing whitespace
(C0303)
[convention] 37-37: Trailing whitespace
(C0303)
[convention] 38-38: Trailing whitespace
(C0303)
[convention] 39-39: Trailing whitespace
(C0303)
[convention] 40-40: Trailing whitespace
(C0303)
[convention] 41-41: Trailing whitespace
(C0303)
[convention] 42-42: Trailing whitespace
(C0303)
[convention] 43-43: Trailing whitespace
(C0303)
[convention] 44-44: Trailing whitespace
(C0303)
[convention] 45-45: Trailing whitespace
(C0303)
[convention] 46-46: Trailing whitespace
(C0303)
[convention] 48-48: Trailing whitespace
(C0303)
[convention] 49-49: Trailing whitespace
(C0303)
[convention] 50-50: Trailing whitespace
(C0303)
[convention] 60-60: Trailing whitespace
(C0303)
[convention] 61-61: Trailing whitespace
(C0303)
[convention] 62-62: Trailing whitespace
(C0303)
[convention] 63-63: Trailing whitespace
(C0303)
[convention] 67-67: Trailing whitespace
(C0303)
[convention] 68-68: Trailing whitespace
(C0303)
[convention] 69-69: Trailing whitespace
(C0303)
[convention] 70-70: Trailing whitespace
(C0303)
[convention] 71-71: Trailing whitespace
(C0303)
[convention] 75-75: Trailing whitespace
(C0303)
[convention] 76-76: Trailing whitespace
(C0303)
[convention] 77-77: Trailing whitespace
(C0303)
[convention] 77-77: Line too long (107/100)
(C0301)
[convention] 78-78: Trailing whitespace
(C0303)
[convention] 79-79: Trailing whitespace
(C0303)
[convention] 80-80: Trailing whitespace
(C0303)
[convention] 80-80: Line too long (102/100)
(C0301)
[convention] 81-81: Trailing whitespace
(C0303)
[convention] 82-82: Trailing whitespace
(C0303)
[convention] 83-83: Trailing whitespace
(C0303)
[convention] 84-84: Trailing whitespace
(C0303)
[convention] 85-85: Trailing whitespace
(C0303)
[convention] 92-92: Trailing whitespace
(C0303)
[convention] 94-94: Trailing whitespace
(C0303)
[convention] 99-99: Final newline missing
(C0304)
[convention] 1-1: Missing module docstring
(C0114)
[error] 2-2: Unable to import 'agentuity'
(E0401)
[error] 3-3: Unable to import 'pydantic'
(E0401)
[error] 5-5: Unable to import 'agents'
(E0401)
[convention] 13-13: Missing class docstring
(C0115)
[refactor] 13-13: Too few public methods (0/2)
(R0903)
[convention] 29-29: Missing function or method docstring
(C0116)
[warning] 94-94: Catching too general exception Exception
(W0718)
[convention] 3-3: third party import "pydantic.BaseModel" should be placed before first party import "agentuity.AgentRequest"
(C0411)
[warning] 1-1: Unused import asyncio
(W0611)
🔇 Additional comments (2)
frameworks/openai/from-oai/my_agents/deterministicStoryAgent/agent.py (2)
8-27: Well-structured agent definitions with clear separation of concerns.The three-agent workflow is well-designed:
- Clear separation between outline generation, quality checking, and story writing
- Proper use of Pydantic model for structured output validation
- Descriptive agent names and instructions
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 8-8: Trailing whitespace
(C0303)
[convention] 9-9: Trailing whitespace
(C0303)
[convention] 10-10: Trailing whitespace
(C0303)
[convention] 11-11: Trailing whitespace
(C0303)
[convention] 12-12: Trailing whitespace
(C0303)
[convention] 13-13: Trailing whitespace
(C0303)
[convention] 14-14: Trailing whitespace
(C0303)
[convention] 15-15: Trailing whitespace
(C0303)
[convention] 16-16: Trailing whitespace
(C0303)
[convention] 17-17: Trailing whitespace
(C0303)
[convention] 18-18: Trailing whitespace
(C0303)
[convention] 19-19: Trailing whitespace
(C0303)
[convention] 19-19: Line too long (112/100)
(C0301)
[convention] 20-20: Trailing whitespace
(C0303)
[convention] 21-21: Trailing whitespace
(C0303)
[convention] 22-22: Trailing whitespace
(C0303)
[convention] 23-23: Trailing whitespace
(C0303)
[convention] 24-24: Trailing whitespace
(C0303)
[convention] 25-25: Trailing whitespace
(C0303)
[convention] 26-26: Trailing whitespace
(C0303)
[convention] 27-27: Trailing whitespace
(C0303)
[convention] 13-13: Missing class docstring
(C0115)
[refactor] 13-13: Too few public methods (0/2)
(R0903)
36-99: Excellent error handling and workflow orchestration.The implementation demonstrates several best practices:
- Proper exception handling with detailed logging
- Type checking for agent outputs before proceeding
- Clear conditional logic for workflow gates
- Consistent use of context propagation to Runner.run calls
- Structured JSON responses for different scenarios (success, rejection, error)
- Good use of trace context for observability
This addresses all the concerns raised in previous reviews and follows the patterns established in other agents.
🧰 Tools
🪛 Pylint (3.3.7)
[convention] 37-37: Trailing whitespace
(C0303)
[convention] 38-38: Trailing whitespace
(C0303)
[convention] 39-39: Trailing whitespace
(C0303)
[convention] 40-40: Trailing whitespace
(C0303)
[convention] 41-41: Trailing whitespace
(C0303)
[convention] 42-42: Trailing whitespace
(C0303)
[convention] 43-43: Trailing whitespace
(C0303)
[convention] 44-44: Trailing whitespace
(C0303)
[convention] 45-45: Trailing whitespace
(C0303)
[convention] 46-46: Trailing whitespace
(C0303)
[convention] 48-48: Trailing whitespace
(C0303)
[convention] 49-49: Trailing whitespace
(C0303)
[convention] 50-50: Trailing whitespace
(C0303)
[convention] 60-60: Trailing whitespace
(C0303)
[convention] 61-61: Trailing whitespace
(C0303)
[convention] 62-62: Trailing whitespace
(C0303)
[convention] 63-63: Trailing whitespace
(C0303)
[convention] 67-67: Trailing whitespace
(C0303)
[convention] 68-68: Trailing whitespace
(C0303)
[convention] 69-69: Trailing whitespace
(C0303)
[convention] 70-70: Trailing whitespace
(C0303)
[convention] 71-71: Trailing whitespace
(C0303)
[convention] 75-75: Trailing whitespace
(C0303)
[convention] 76-76: Trailing whitespace
(C0303)
[convention] 77-77: Trailing whitespace
(C0303)
[convention] 77-77: Line too long (107/100)
(C0301)
[convention] 78-78: Trailing whitespace
(C0303)
[convention] 79-79: Trailing whitespace
(C0303)
[convention] 80-80: Trailing whitespace
(C0303)
[convention] 80-80: Line too long (102/100)
(C0301)
[convention] 81-81: Trailing whitespace
(C0303)
[convention] 82-82: Trailing whitespace
(C0303)
[convention] 83-83: Trailing whitespace
(C0303)
[convention] 84-84: Trailing whitespace
(C0303)
[convention] 85-85: Trailing whitespace
(C0303)
[convention] 92-92: Trailing whitespace
(C0303)
[convention] 94-94: Trailing whitespace
(C0303)
[convention] 99-99: Final newline missing
(C0304)
[warning] 94-94: Catching too general exception Exception
(W0718)
Added some examples using the OpenAI Agents SDK --> TutorAgent, Translation Agent, Deterministic Story Agent...
Summary by CodeRabbit
New Features
Documentation
Chores