Skip to content

[BUG] cannot call agent multiple times when custom http_client is passed #906

@larbikhalid

Description

@larbikhalid

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.9.1

Python Version

3.13

Operating System

Ubuntu

Installation Method

pip

Steps to Reproduce

import httpx
from strands.models.openai import OpenAIModel
from strands import Agent

model = OpenAIModel(
    client_args={
        "api_key": "EMPTY",
        "base_url" : "https://localhost:8000/v1",
        "http_client": httpx.AsyncClient(verify=False),
    },
    model_id="openai/gpt-oss-20b",
    params={
        "tool_choice": "auto"
    }
)

agent = Agent(
    model=model,
)

agent("Hello")

print("Works fine")

agent("Hello again")

print("This print is not reached")

This code is working fine on 1.7.1 and was introduced in 1.9.0 in the next PR:

@pgrayy could you help with this issue please?

Expected Behavior

Expect to call same agent multiple times.

Actual Behavior

Only first agent is called correctly. Subsequent calls get failed saying that the connection is already closed

Additional Context

No response

Possible Solution

No response

Related Issues

https://github.com/strands-agents/sdk-python/pull/856/files

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-asyncRelated to asynchronous flows or multi-threadingarea-providerRelated to model providersbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions