@@ -15,7 +15,7 @@ namespace Devlooped.Agents.AI;
1515/// A configuration-driven <see cref="AIAgent"/> which monitors configuration changes and
1616/// re-applies them to the inner agent automatically.
1717/// </summary>
18- public sealed partial class ConfigurableAIAgent : AIAgent , IDisposable
18+ public sealed partial class ConfigurableAIAgent : AIAgent , IHasAdditionalProperties , IDisposable
1919{
2020 readonly IServiceProvider services ;
2121 readonly IConfiguration configuration ;
@@ -57,6 +57,9 @@ Type t when typeof(AIAgentMetadata).IsAssignableFrom(t) => metadata,
5757 _ => agent . GetService ( serviceType , serviceKey )
5858 } ;
5959
60+ /// <inheritdoc/>
61+ public AdditionalPropertiesDictionary ? AdditionalProperties { get ; set ; }
62+
6063 /// <inheritdoc/>
6164 public override string Id => agent . Id ;
6265 /// <inheritdoc/>
@@ -89,6 +92,20 @@ public override IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync(IEnum
8992 options ? . Description = options? . Description ? . Dedent ( ) ;
9093 options ? . Instructions = options? . Instructions ? . Dedent ( ) ;
9194
95+ var properties = configSection . Get < AdditionalPropertiesDictionary > ( ) ;
96+ if ( properties is not null )
97+ {
98+ properties ? . Remove ( nameof ( AgentClientOptions . Name ) ) ;
99+ properties ? . Remove ( nameof ( AgentClientOptions . Description ) ) ;
100+ properties ? . Remove ( nameof ( AgentClientOptions . Instructions ) ) ;
101+ properties ? . Remove ( nameof ( AgentClientOptions . Client ) ) ;
102+ properties ? . Remove ( nameof ( AgentClientOptions . Model ) ) ;
103+ properties ? . Remove ( nameof ( AgentClientOptions . Use ) ) ;
104+ properties ? . Remove ( nameof ( AgentClientOptions . Tools ) ) ;
105+
106+ AdditionalProperties = properties ;
107+ }
108+
92109 // If there was a custom id, we must validate it didn't change since that's not supported.
93110 if ( configuration [ $ "{ section } :name"] is { } newname && newname != name )
94111 throw new InvalidOperationException ( $ "The name of a configured agent cannot be changed at runtime. Expected '{ name } ' but was '{ newname } '.") ;
0 commit comments