Skip to content

Agent has error calling tool even if is_enabled = True #2232

@NateMoneyLion

Description

@NateMoneyLion

Question

  1. I'm using the is_enabled param within the @function_tool decorator to control the tools that are exposed to a user at runtime based on the callable function below to control the value for is_enabled
def _is_cm_enrolled(ctx: RunContextWrapper[AgentContext], agent: AgentBase) -> bool:
    return ctx.context.is_cm_enrolled  # by default is True
  1. I always bump into this error if the opening query for the session already calls a tool e.g. "what's my credit score?".
agents.exceptions.ModelBehaviorError: Tool fetch_latest_credit_report" /> not found in agent Agent

Implementation of tool as follows:

@function_tool(is_enabled=_is_cm_enrolled)
async def fetch_latest_credit_report(
    wrapper: RunContextWrapper[AgentContext],
) -> dict | None:
    """
    High level data points e.g.
    - credit score
    - credit utilization rate
    - credit age
    - credit inquiries
    - payment history
    """
    data = await _credit_report_retriever_client._fetch(
          request={
              "user_id": "",
              "request_source": "",
          },
      )

    return data
  1. However, if the opening query is something generic like "hello", this error doesn't bubble up.

Am I doing something wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion about using the SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions