Skip to content

Commit 057a28f

Browse files
Merge branch 'u/fix#4618' of https://github.com/microsoft/autogen into u/fix#4618
2 parents e4768d9 + 3d21a94 commit 057a28f

File tree

132 files changed

+2496
-2274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2496
-2274
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
{ ref: "v0.4.0.dev7", dest-dir: "0.4.0.dev7" },
4343
{ ref: "v0.4.0.dev8", dest-dir: "0.4.0.dev8" },
4444
{ ref: "v0.4.0.dev9", dest-dir: "0.4.0.dev9" },
45+
{ ref: "v0.4.0.dev10", dest-dir: "0.4.0.dev10" },
46+
{ ref: "v0.4.0.dev11", dest-dir: "0.4.0.dev11" },
4547
]
4648
steps:
4749
- name: Checkout

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ We will update verion numbers according to the following rules:
4949

5050
1. Create a PR that updates the version numbers across the codebase ([example](https://github.com/microsoft/autogen/pull/4359))
5151
2. The docs CI will fail for the PR, but this is expected and will be resolved in the next step
52-
2. After merging the PR, create and push a tag that corresponds to the new verion. For example, for `0.4.0.dev9`:
53-
- `git tag 0.4.0.dev9 && git push origin 0.4.0.dev9`
52+
2. After merging the PR, create and push a tag that corresponds to the new verion. For example, for `0.4.0.dev11`:
53+
- `git tag 0.4.0.dev11 && git push origin 0.4.0.dev11`
5454
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
5555
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
5656

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
<div align="center">
44
<img src="https://microsoft.github.io/autogen/0.2/img/ag.svg" alt="AutoGen Logo" width="100">
55

6-
[![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)
7-
[![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/)
8-
[![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/0.4.0.dev9/) [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/0.4.0.dev9/) [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/0.4.0.dev9/)
6+
[![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/)
97

8+
[![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/)
109
</div>
1110

1211
# AutoGen
@@ -105,7 +104,7 @@ We look forward to your contributions!
105104
First install the packages:
106105

107106
```bash
108-
pip install 'autogen-agentchat==0.4.0.dev9' 'autogen-ext[openai]==0.4.0.dev9'
107+
pip install 'autogen-agentchat==0.4.0.dev11' 'autogen-ext[openai]==0.4.0.dev11'
109108
```
110109

111110
The following code uses OpenAI's GPT-4o model and you need to provide your
@@ -119,7 +118,7 @@ from autogen_agentchat.agents import AssistantAgent
119118
from autogen_agentchat.ui import Console
120119
from autogen_agentchat.conditions import TextMentionTermination
121120
from autogen_agentchat.teams import RoundRobinGroupChat
122-
from autogen_ext.models import OpenAIChatCompletionClient
121+
from autogen_ext.models.openai import OpenAIChatCompletionClient
123122

124123
# Define a tool
125124
async def get_weather(city: str) -> str:

docs/switcher.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@
5656
{
5757
"name": "0.4.0.dev9",
5858
"version": "0.4.0.dev9",
59-
"url": "/autogen/0.4.0.dev9/",
59+
"url": "/autogen/0.4.0.dev9/"
60+
},
61+
{
62+
"name": "0.4.0.dev10",
63+
"version": "0.4.0.dev10",
64+
"url": "/autogen/0.4.0.dev10/"
65+
},
66+
{
67+
"name": "0.4.0.dev11",
68+
"version": "0.4.0.dev11",
69+
"url": "/autogen/0.4.0.dev11/",
6070
"preferred": true
6171
}
6272
]

dotnet/src/Microsoft.AutoGen/Abstractions/IAgentWorker.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// IAgentWorker.cs
3-
43
namespace Microsoft.AutoGen.Abstractions;
54

65
public interface IAgentWorker

dotnet/src/Microsoft.AutoGen/Abstractions/MessageExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static CloudEvent ToCloudEvent<T>(this T message, string source) where T
1717
Type = message.Descriptor.FullName,
1818
Source = source,
1919
Id = Guid.NewGuid().ToString(),
20+
SpecVersion = "1.0",
2021
Attributes = { { "datacontenttype", new CloudEvent.Types.CloudEventAttributeValue { CeString = PROTO_DATA_CONTENT_TYPE } } }
2122
};
2223
}

dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected internal async Task HandleRpcMessage(Message msg, CancellationToken ca
131131
{
132132
case Message.MessageOneofCase.CloudEvent:
133133
{
134-
var activity = this.ExtractActivity(msg.CloudEvent.Type, msg.CloudEvent.Metadata);
134+
var activity = this.ExtractActivity(msg.CloudEvent.Type, msg.CloudEvent.Attributes);
135135
await this.InvokeWithActivityAsync(
136136
static ((AgentBase Agent, CloudEvent Item) state, CancellationToken _) => state.Agent.CallHandler(state.Item),
137137
(this, msg.CloudEvent),

dotnet/src/Microsoft.AutoGen/Agents/AgentBaseExtensions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// AgentBaseExtensions.cs
33

44
using System.Diagnostics;
5+
using Google.Protobuf.Collections;
6+
using static Microsoft.AutoGen.Abstractions.CloudEvent.Types;
57

68
namespace Microsoft.AutoGen.Agents;
79

@@ -57,6 +59,11 @@ public static class AgentBaseExtensions
5759
return activity;
5860
}
5961

62+
public static Activity? ExtractActivity(this AgentBase agent, string activityName, MapField<string, CloudEventAttributeValue> metadata)
63+
{
64+
return ExtractActivity(agent, activityName, metadata.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.CeString));
65+
}
66+
6067
/// <summary>
6168
/// Invokes a function asynchronously within the context of an <see cref="Activity"/>.
6269
/// </summary>

dotnet/src/Microsoft.AutoGen/Agents/AgentRuntime.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// AgentRuntime.cs
33

44
using System.Diagnostics;
5+
using Google.Protobuf.Collections;
56
using Microsoft.AutoGen.Abstractions;
67
using Microsoft.Extensions.Logging;
8+
using static Microsoft.AutoGen.Abstractions.CloudEvent.Types;
79

810
namespace Microsoft.AutoGen.Agents;
911

@@ -28,13 +30,49 @@ internal sealed class AgentRuntime(AgentId agentId, IAgentWorker worker, ILogger
2830
out var traceState);
2931
return (traceParent, traceState);
3032
}
33+
public (string?, string?) GetTraceIdAndState(MapField<string, CloudEventAttributeValue> metadata)
34+
{
35+
DistributedContextPropagator.ExtractTraceIdAndState(metadata,
36+
static (object? carrier, string fieldName, out string? fieldValue, out IEnumerable<string>? fieldValues) =>
37+
{
38+
var metadata = (MapField<string, CloudEventAttributeValue>)carrier!;
39+
fieldValues = null;
40+
metadata.TryGetValue(fieldName, out var ceValue);
41+
fieldValue = ceValue?.CeString;
42+
},
43+
out var traceParent,
44+
out var traceState);
45+
return (traceParent, traceState);
46+
}
3147
public void Update(RpcRequest request, Activity? activity = null)
3248
{
33-
DistributedContextPropagator.Inject(activity, request.Metadata, static (carrier, key, value) => ((IDictionary<string, string>)carrier!)[key] = value);
49+
DistributedContextPropagator.Inject(activity, request.Metadata, static (carrier, key, value) =>
50+
{
51+
var metadata = (IDictionary<string, string>)carrier!;
52+
if (metadata.TryGetValue(key, out _))
53+
{
54+
metadata[key] = value;
55+
}
56+
else
57+
{
58+
metadata.Add(key, value);
59+
}
60+
});
3461
}
3562
public void Update(CloudEvent cloudEvent, Activity? activity = null)
3663
{
37-
DistributedContextPropagator.Inject(activity, cloudEvent.Metadata, static (carrier, key, value) => ((IDictionary<string, string>)carrier!)[key] = value);
64+
DistributedContextPropagator.Inject(activity, cloudEvent.Attributes, static (carrier, key, value) =>
65+
{
66+
var mapField = (MapField<string, CloudEventAttributeValue>)carrier!;
67+
if (mapField.TryGetValue(key, out var ceValue))
68+
{
69+
mapField[key] = new CloudEventAttributeValue { CeString = value };
70+
}
71+
else
72+
{
73+
mapField.Add(key, new CloudEventAttributeValue { CeString = value });
74+
}
75+
});
3876
}
3977
public async ValueTask SendResponseAsync(RpcRequest request, RpcResponse response, CancellationToken cancellationToken = default)
4078
{
@@ -73,4 +111,17 @@ public IDictionary<string, string> ExtractMetadata(IDictionary<string, string> m
73111

74112
return baggage as IDictionary<string, string> ?? new Dictionary<string, string>();
75113
}
114+
115+
public IDictionary<string, string> ExtractMetadata(MapField<string, CloudEventAttributeValue> metadata)
116+
{
117+
var baggage = DistributedContextPropagator.ExtractBaggage(metadata, static (object? carrier, string fieldName, out string? fieldValue, out IEnumerable<string>? fieldValues) =>
118+
{
119+
var metadata = (MapField<string, CloudEventAttributeValue>)carrier!;
120+
fieldValues = null;
121+
metadata.TryGetValue(fieldName, out var ceValue);
122+
fieldValue = ceValue?.CeString;
123+
});
124+
125+
return baggage as IDictionary<string, string> ?? new Dictionary<string, string>();
126+
}
76127
}

protos/agent_worker.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ message Message {
117117
oneof message {
118118
RpcRequest request = 1;
119119
RpcResponse response = 2;
120-
cloudevent.CloudEvent cloudEvent = 3;
120+
io.cloudevents.v1.CloudEvent cloudEvent = 3;
121121
RegisterAgentTypeRequest registerAgentTypeRequest = 4;
122122
RegisterAgentTypeResponse registerAgentTypeResponse = 5;
123123
AddSubscriptionRequest addSubscriptionRequest = 6;

0 commit comments

Comments
 (0)