diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 703c07494251..6d99af595cff 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -61,7 +61,7 @@ jobs: ] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -89,7 +89,7 @@ jobs: ] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -115,7 +115,7 @@ jobs: ] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -139,7 +139,7 @@ jobs: package: ["./packages/autogen-core"] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -160,7 +160,7 @@ jobs: package: ["./packages/autogen-core"] steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -178,7 +178,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 76457b6d815f..6c2ca98ccedb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -61,7 +61,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up Python + - name: Set up Python uses: actions/setup-python@v5 with: python-version: 3.11 @@ -73,7 +73,7 @@ jobs: - name: list available kernels run: | python -m jupyter kernelspec list - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - run: uv sync --locked --all-extras diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 6908ef929f4f..43c52f6bc59f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -31,19 +31,21 @@ jobs: matrix: version: [ - { ref: main, dest-dir: dev }, - { ref: "v0.4.0.dev0", dest-dir: "0.4.0.dev0" }, - { ref: "v0.4.0.dev1", dest-dir: "0.4.0.dev1" }, - { ref: "v0.4.0.dev2", dest-dir: "0.4.0.dev2" }, - { ref: "v0.4.0.dev3", dest-dir: "0.4.0.dev3" }, - { ref: "v0.4.0.dev4", dest-dir: "0.4.0.dev4" }, - { ref: "v0.4.0.dev5", dest-dir: "0.4.0.dev5" }, - { ref: "v0.4.0.dev6", dest-dir: "0.4.0.dev6" }, - { ref: "v0.4.0.dev7", dest-dir: "0.4.0.dev7" }, - { ref: "v0.4.0.dev8", dest-dir: "0.4.0.dev8" }, - { ref: "v0.4.0.dev9", dest-dir: "0.4.0.dev9" }, - { ref: "v0.4.0.dev10", dest-dir: "0.4.0.dev10" }, - { ref: "v0.4.0.dev11", dest-dir: "0.4.0.dev11" }, + # For main use the workflow target + { ref: "${{github.ref}}", dest-dir: dev, uv-version: "0.5.13" }, + { ref: "v0.4.0.dev0", dest-dir: "0.4.0.dev0", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev1", dest-dir: "0.4.0.dev1", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev2", dest-dir: "0.4.0.dev2", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev3", dest-dir: "0.4.0.dev3", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev4", dest-dir: "0.4.0.dev4", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev5", dest-dir: "0.4.0.dev5", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev6", dest-dir: "0.4.0.dev6", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev7", dest-dir: "0.4.0.dev7", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev8", dest-dir: "0.4.0.dev8", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev9", dest-dir: "0.4.0.dev9", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev10", dest-dir: "0.4.0.dev10", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev11", dest-dir: "0.4.0.dev11", uv-version: "0.5.11" }, + { ref: "v0.4.0.dev12", dest-dir: "0.4.0.dev12", uv-version: "0.5.13" }, ] steps: - name: Checkout @@ -51,9 +53,10 @@ jobs: with: lfs: "true" ref: ${{ matrix.version.ref }} - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true + version: ${{ matrix.version.uv-version }} - uses: actions/setup-python@v5 with: python-version: "3.11" @@ -99,7 +102,7 @@ jobs: with: lfs: "true" ref: ${{ matrix.version.ref }} - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index e70a943ccd7e..06a9713dfcc2 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -76,7 +76,7 @@ jobs: - name: list available kernels run: | python -m jupyter kernelspec list - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - run: uv sync --locked --all-extras @@ -103,10 +103,10 @@ jobs: dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true - name: Unit Test run: dotnet test --no-build -bl --configuration Release --filter type=!integration - + integration-test: strategy: - fail-fast: true + fail-fast: true matrix: os: [ ubuntu-latest] version: [ net8.0 ] @@ -119,7 +119,7 @@ jobs: - uses: actions/checkout@v4 with: lfs: true - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -203,7 +203,7 @@ jobs: - name: list available kernels run: | python -m jupyter kernelspec list - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - uses: actions/setup-python@v5 @@ -299,4 +299,4 @@ jobs: env: MYGET_TOKEN: ${{ secrets.MYGET_TOKEN }} continue-on-error: true - + diff --git a/.github/workflows/single-python-package.yml b/.github/workflows/single-python-package.yml index db761e2c2563..b4657a5f5163 100644 --- a/.github/workflows/single-python-package.yml +++ b/.github/workflows/single-python-package.yml @@ -32,7 +32,7 @@ jobs: ref: ${{ github.event.inputs.ref }} # Require ref to be a tag - run: git show-ref --verify refs/tags/${{ github.event.inputs.ref }} - - uses: astral-sh/setup-uv@v3 + - uses: astral-sh/setup-uv@v5 with: enable-cache: true - run: uv build --package ${{ github.event.inputs.package }} --out-dir dist/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3dcccbb1811d..ab86f7ed1185 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,8 +49,8 @@ We will update verion numbers according to the following rules: 1. Create a PR that updates the version numbers across the codebase ([example](https://github.com/microsoft/autogen/pull/4359)) 2. The docs CI will fail for the PR, but this is expected and will be resolved in the next step -2. After merging the PR, create and push a tag that corresponds to the new verion. For example, for `0.4.0.dev11`: - - `git tag 0.4.0.dev11 && git push origin 0.4.0.dev11` +2. After merging the PR, create and push a tag that corresponds to the new verion. For example, for `0.4.0.dev12`: + - `git tag 0.4.0.dev12 && git push origin 0.4.0.dev12` 3. Restart the docs CI by finding the failed [job corresponding to the `push` event](https://github.com/microsoft/autogen/actions/workflows/docs.yml) and restarting all jobs 4. Run [this](https://github.com/microsoft/autogen/actions/workflows/single-python-package.yml) workflow for each of the packages that need to be released and get an approval for the release for it to run diff --git a/README.md b/README.md index 0e6702f2a3dd..6efb8051dad7 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen) [![LinkedIn](https://img.shields.io/badge/LinkedIn-Company?style=flat&logo=linkedin&logoColor=white)](https://www.linkedin.com/company/105812540) [![Discord](https://img.shields.io/badge/discord-chat-green?logo=discord)](https://aka.ms/autogen-discord) [![GitHub Discussions](https://img.shields.io/badge/Discussions-Q%26A-green?logo=github)](https://github.com/microsoft/autogen/discussions) [![0.2 Docs](https://img.shields.io/badge/Docs-0.2-blue)](https://microsoft.github.io/autogen/0.2/) [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/) -[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev11/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev11/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev11/) +[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev12/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev12/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev12/) # AutoGen > [!IMPORTANT] > -> - (12/19/24) Hello! +> - (12/19/24) Hello! The majority of the AutoGen Team members will be resting and recharging with family and friends over the holiday period. Activity/responses on the project may be delayed during the period of Dec 20-Jan 06. We will be excited to engage with you in the new year! > - (12/11/24) We have created a new Discord server for the AutoGen community. Join us at [aka.ms/autogen-discord](https://aka.ms/autogen-discord). > - (11/14/24) ⚠️ In response to a number of asks to clarify and distinguish between official AutoGen and its forks that created confusion, we issued a [clarification statement](https://github.com/microsoft/autogen/discussions/4217). @@ -20,7 +20,6 @@ The majority of the AutoGen Team members will be resting and recharging with fam > - (10/02/24) [AutoGen 0.4](https://microsoft.github.io/autogen/dev) is a from-the-ground-up rewrite of AutoGen. Learn more about the history, goals and future at [this blog post](https://microsoft.github.io/autogen/blog). We’re excited to work with the community to gather feedback, refine, and improve the project before we officially release 0.4. This is a big change, so AutoGen 0.2 is still available, maintained, and developed in the [0.2 branch](https://github.com/microsoft/autogen/tree/0.2). > - *[Join us for Community Office Hours](https://github.com/microsoft/autogen/discussions/4059)* We will host a weekly open discussion to answer questions, talk about Roadmap, etc. - AutoGen is an open-source framework for building AI agent systems. It simplifies the creation of event-driven, distributed, scalable, and resilient agentic applications. It allows you to quickly build systems where AI agents collaborate and perform tasks autonomously @@ -108,7 +107,7 @@ We look forward to your contributions! First install the packages: ```bash -pip install "autogen-agentchat==0.4.0.dev11" "autogen-ext[openai]==0.4.0.dev11" +pip install "autogen-agentchat==0.4.0.dev12" "autogen-ext[openai]==0.4.0.dev12" ``` The following code uses OpenAI's GPT-4o model and you need to provide your diff --git a/docs/switcher.json b/docs/switcher.json index 205f954c7329..fa2c2745a233 100644 --- a/docs/switcher.json +++ b/docs/switcher.json @@ -66,7 +66,12 @@ { "name": "0.4.0.dev11", "version": "0.4.0.dev11", - "url": "/autogen/0.4.0.dev11/", + "url": "/autogen/0.4.0.dev11/" + }, + { + "name": "0.4.0.dev12", + "version": "0.4.0.dev12", + "url": "/autogen/0.4.0.dev12/", "preferred": true } ] diff --git a/dotnet/src/AutoGen/LMStudioConfig.cs b/dotnet/src/AutoGen/LMStudioConfig.cs index 4605b051142f..29c60ff13f39 100644 --- a/dotnet/src/AutoGen/LMStudioConfig.cs +++ b/dotnet/src/AutoGen/LMStudioConfig.cs @@ -13,18 +13,28 @@ namespace AutoGen; /// public class LMStudioConfig : ILLMConfig { - public LMStudioConfig(string host, int port) + public LMStudioConfig(string host, int port, string modelName) { this.Host = host; this.Port = port; - this.Uri = new Uri($"http://{host}:{port}"); + this.Uri = new Uri($"http://{host}:{port}/v1"); + if (modelName == null) + { + throw new ArgumentNullException("modelName is a required property for LMStudioConfig and cannot be null"); + } + this.ModelName = modelName; } - public LMStudioConfig(Uri uri) + public LMStudioConfig(Uri uri, string modelName) { this.Uri = uri; this.Host = uri.Host; this.Port = uri.Port; + if (modelName == null) + { + throw new ArgumentNullException("modelName is a required property for LMStudioConfig and cannot be null"); + } + this.ModelName = modelName; } public string Host { get; } @@ -33,6 +43,8 @@ public LMStudioConfig(Uri uri) public Uri Uri { get; } + public string ModelName { get; } + internal ChatClient CreateChatClient() { var client = new OpenAIClient(new ApiKeyCredential("api-key"), new OpenAIClientOptions @@ -40,8 +52,6 @@ internal ChatClient CreateChatClient() Endpoint = this.Uri, }); - // model name doesn't matter for LM Studio - - return client.GetChatClient("model-name"); + return client.GetChatClient(this.ModelName); } } diff --git a/python/README.md b/python/README.md index 24cb7e796334..0007d3ae70a2 100644 --- a/python/README.md +++ b/python/README.md @@ -1,7 +1,7 @@ # AutoGen Python packages [![0.4 Docs](https://img.shields.io/badge/Docs-0.4-blue)](https://microsoft.github.io/autogen/dev/) -[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev11/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev11/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev11/) +[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev12/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev12/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev12/) This directory works as a single `uv` workspace containing all project packages. See [`packages`](./packages/) to discover all project packages. diff --git a/python/packages/agbench/pyproject.toml b/python/packages/agbench/pyproject.toml index 7cdfc89c0ec9..de5f9df22af7 100644 --- a/python/packages/agbench/pyproject.toml +++ b/python/packages/agbench/pyproject.toml @@ -28,8 +28,8 @@ dependencies = [ "scipy" ] -[tool.uv] -dev-dependencies = [ +[dependency-groups] +dev = [ "types-tabulate", "types-docker" ] diff --git a/python/packages/autogen-agentchat/pyproject.toml b/python/packages/autogen-agentchat/pyproject.toml index 5f11afc07751..273792d33584 100644 --- a/python/packages/autogen-agentchat/pyproject.toml +++ b/python/packages/autogen-agentchat/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "autogen-agentchat" -version = "0.4.0.dev11" +version = "0.4.0.dev12" license = {file = "LICENSE-CODE"} description = "AutoGen agents and teams library" readme = "README.md" @@ -15,13 +15,9 @@ classifiers = [ "Operating System :: OS Independent", ] dependencies = [ - "autogen-core==0.4.0.dev11", + "autogen-core==0.4.0.dev12", ] -[tool.uv] -dev-dependencies = [] - - [tool.ruff] extend = "../../pyproject.toml" include = ["src/**", "tests/*.py"] diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py index 29961229c568..ea4d3d2b2a5b 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py @@ -72,6 +72,14 @@ class AssistantAgent(BaseChatAgent): the inner messages as they are created, and the :class:`~autogen_agentchat.base.Response` object as the last item before closing the generator. + + .. note:: + + The caller must only pass the new messages to the agent on each call + to the :meth:`on_messages` or :meth:`on_messages_stream` method. + The agent maintains its state between calls to these methods. + Do not pass the entire conversation history to the agent on each call. + Tool call behavior: * If the model returns no tool call, then the response is immediately returned as a :class:`~autogen_agentchat.messages.TextMessage` in :attr:`~autogen_agentchat.base.Response.chat_message`. @@ -290,7 +298,9 @@ def __init__( raise ValueError( f"Handoff names must be unique from tool names. Handoff names: {handoff_tool_names}; tool names: {tool_names}" ) - if not model_context: + if model_context is not None: + self._model_context = model_context + else: self._model_context = UnboundedChatCompletionContext() self._reflect_on_tool_use = reflect_on_tool_use self._tool_call_summary_format = tool_call_summary_format diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py index 5b41d7bea331..c78c9adb90ee 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py @@ -14,7 +14,26 @@ class BaseChatAgent(ChatAgent, ABC): - """Base class for a chat agent.""" + """Base class for a chat agent. + + This abstract class provides a base implementation for a :class:`ChatAgent`. + To create a new chat agent, subclass this class and implement the + :meth:`on_messages`, :meth:`on_reset`, and :attr:`produced_message_types`. + If streaming is required, also implement the :meth:`on_messages_stream` method. + + An agent is considered stateful and maintains its state between calls to + the :meth:`on_messages` or :meth:`on_messages_stream` methods. + The agent should store its state in the + agent instance. The agent should also implement the :meth:`on_reset` method + to reset the agent to its initialization state. + + .. note:: + + The caller should only pass the new messages to the agent on each call + to the :meth:`on_messages` or :meth:`on_messages_stream` method. + Do not pass the entire conversation history to the agent on each call. + This design principle must be followed when creating a new agent. + """ def __init__(self, name: str, description: str) -> None: self._name = name diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py index 6b8ab305579f..1695be4267c0 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_user_proxy_agent.py @@ -48,7 +48,7 @@ class UserProxyAgent(BaseChatAgent): You can run the team again with the user input. This way, the state of the team can be saved and restored when the user responds. - See `Pause for User Input `_ for more information. + See `Human-in-the-loop `_ for more information. Example: Simple usage case:: diff --git a/python/packages/autogen-agentchat/tests/test_assistant_agent.py b/python/packages/autogen-agentchat/tests/test_assistant_agent.py index 9065d5139180..48f51c4712ed 100644 --- a/python/packages/autogen-agentchat/tests/test_assistant_agent.py +++ b/python/packages/autogen-agentchat/tests/test_assistant_agent.py @@ -17,6 +17,8 @@ ToolCallSummaryMessage, ) from autogen_core import Image +from autogen_core.model_context import BufferedChatCompletionContext +from autogen_core.models import LLMMessage from autogen_core.tools import FunctionTool from autogen_ext.models.openai import OpenAIChatCompletionClient from openai.resources.chat.completions import AsyncCompletions @@ -39,10 +41,12 @@ class _MockChatCompletion: def __init__(self, chat_completions: List[ChatCompletion]) -> None: self._saved_chat_completions = chat_completions self.curr_index = 0 + self.calls: List[List[LLMMessage]] = [] async def mock_create( self, *args: Any, **kwargs: Any ) -> ChatCompletion | AsyncGenerator[ChatCompletionChunk, None]: + self.calls.append(kwargs["messages"]) # Save the call await asyncio.sleep(0.1) completion = self._saved_chat_completions[self.curr_index] self.curr_index += 1 @@ -468,3 +472,43 @@ async def test_list_chat_messages(monkeypatch: pytest.MonkeyPatch) -> None: else: assert message == result.messages[index] index += 1 + + +@pytest.mark.asyncio +async def test_model_context(monkeypatch: pytest.MonkeyPatch) -> None: + model = "gpt-4o-2024-05-13" + chat_completions = [ + ChatCompletion( + id="id1", + choices=[ + Choice( + finish_reason="stop", + index=0, + message=ChatCompletionMessage(content="Response to message 3", role="assistant"), + ) + ], + created=0, + model=model, + object="chat.completion", + usage=CompletionUsage(prompt_tokens=10, completion_tokens=5, total_tokens=15), + ), + ] + mock = _MockChatCompletion(chat_completions) + monkeypatch.setattr(AsyncCompletions, "create", mock.mock_create) + model_context = BufferedChatCompletionContext(buffer_size=2) + agent = AssistantAgent( + "test_agent", + model_client=OpenAIChatCompletionClient(model=model, api_key=""), + model_context=model_context, + ) + + messages = [ + TextMessage(content="Message 1", source="user"), + TextMessage(content="Message 2", source="user"), + TextMessage(content="Message 3", source="user"), + ] + await agent.run(task=messages) + + # Check if the mock client is called with only the last two messages. + assert len(mock.calls) == 1 + assert len(mock.calls[0]) == 3 # 2 message from the context + 1 system message diff --git a/python/packages/autogen-core/docs/drawio/human-in-the-loop-termination.drawio b/python/packages/autogen-core/docs/drawio/human-in-the-loop-termination.drawio new file mode 100644 index 000000000000..1c4b1564b4c8 --- /dev/null +++ b/python/packages/autogen-core/docs/drawio/human-in-the-loop-termination.drawio @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/packages/autogen-core/docs/drawio/human-in-the-loop-user-proxy.drawio b/python/packages/autogen-core/docs/drawio/human-in-the-loop-user-proxy.drawio new file mode 100644 index 000000000000..6b392341ea5a --- /dev/null +++ b/python/packages/autogen-core/docs/drawio/human-in-the-loop-user-proxy.drawio @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/packages/autogen-core/docs/src/_templates/sidebar-nav-bs-agentchat.html b/python/packages/autogen-core/docs/src/_templates/sidebar-nav-bs-agentchat.html index 684eb304ac7f..cce87d18d1ca 100644 --- a/python/packages/autogen-core/docs/src/_templates/sidebar-nav-bs-agentchat.html +++ b/python/packages/autogen-core/docs/src/_templates/sidebar-nav-bs-agentchat.html @@ -1,38 +1,39 @@ {# Displays the TOC-subtree for pages nested under the currently active top-level TOCtree element. #} -