Skip to content

PyCharm Fails to Recognize Agent Constructor Arguments (v0.0.15) #712

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

Open
masfernandez opened this issue May 18, 2025 · 4 comments
Open
Labels
question Question about using the SDK

Comments

@masfernandez
Copy link

masfernandez commented May 18, 2025

Hi everyone,

I'm having an issue with PyCharm 2025.1.1 not correctly recognizing arguments for Agent when using openai-agents==0.0.15 on Python 3.13.3.

The Problem:
PyCharm flags valid parameters like name, instructions, model, tools, etc., with warnings (yellow squiggles) and doesn't provide any auto-suggestions or parameter info for them.

Key Details:

  • The code runs perfectly fine. This seems to be purely an IDE static analysis/code intelligence issue.
  • The problem persists even in a brand new, minimal project with only openai-agents installed.
  • Navigating to the Agent class (Ctrl+Click) works and shows it's a @DataClass.
  • PyCharm caches have been invalidated multiple times.

Environment:

  • openai-agents version: 0.0.15
  • Python version: 3.13.3
  • IDE: PyCharm 2025.1.1

Has anyone else experienced this or have any ideas what might be causing PyCharm to struggle with the Agent dataclass definition or how to get auto-suggestions working? Any tips would be appreciated!

Thanks!

Image
@masfernandez masfernandez added the question Question about using the SDK label May 18, 2025
@hudson155
Copy link

Having this issue too

@hettiger
Copy link

That seems to happen, because Agent is generic. I don't use a context in my app right now. Therefore, I've added a custom agent base class as follows:

from agents import Agent


class BaseAgent(Agent[None]):
    pass

This defines the Generic[TContext] to be of type None and makes PyCharm happy.

Image

I'm running on 0.0.16

I think this is not a ideal solution. It would be awesome to see this fixed so my workaround is no longer needed.

@masfernandez
Copy link
Author

Thanks for sharing it @hettiger, it works very well. I was just begining to learning the SDK at the moment and for me it is a great help.

There is an example on the page https://openai.github.io/openai-agents-python/context/ with a UserInfo context and it seems that PyCharm also marks it as a warning (quite annoying).

Image

@hettiger
Copy link

Yes, that's unfortunate @masfernandez

Hopefully, we'll get improved docs or implementation is updated so this works without some extra tricks you have to come up with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about using the SDK
Projects
None yet
Development

No branches or pull requests

3 participants