Skip to content

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

Not planned
@masfernandez

Description

@masfernandez

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

Activity

hudson155

hudson155 commented on May 21, 2025

@hudson155

Having this issue too

hettiger

hettiger commented on May 23, 2025

@hettiger

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

masfernandez commented on May 24, 2025

@masfernandez
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

hettiger commented on May 24, 2025

@hettiger

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.

github-actions

github-actions commented on Jun 1, 2025

@github-actions

This issue is stale because it has been open for 7 days with no activity.

davidheryanto

davidheryanto commented on Jun 5, 2025

@davidheryanto

I believe this is the related issue
https://youtrack.jetbrains.com/issue/PY-78250/Generic-dataclasses-dont-work-with-TypeVar-when-it-has-a-default-value

I tried installing PyCharm 2025.2 EAP, the warning is no longer there.

masfernandez

masfernandez commented on Jun 5, 2025

@masfernandez
Author

I'll keep an eye on it. Thanks for sharing @davidheryanto

github-actions

github-actions commented on Jun 13, 2025

@github-actions

This issue is stale because it has been open for 7 days with no activity.

github-actions

github-actions commented on Jun 16, 2025

@github-actions

This issue was closed because it has been inactive for 3 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDKstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hudson155@hettiger@davidheryanto@masfernandez

        Issue actions

          PyCharm Fails to Recognize Agent Constructor Arguments (v0.0.15) · Issue #712 · openai/openai-agents-python