feat: Microsoft.Extensions.AI IChatClient integration#2
Conversation
Implement ManagedCode.CodexSharpSDK.Extensions.AI adapter package that bridges CodexSharpSDK to the standard IChatClient interface from Microsoft.Extensions.AI.Abstractions. New package: - CodexChatClient : IChatClient with sync/streaming support - Custom AIContent types: CommandExecution, FileChange, McpToolCall, WebSearch, CollabToolCall - Internal mappers: ChatMessage, ChatOptions, ChatResponse, Streaming - DI extensions: AddCodexChatClient / AddKeyedCodexChatClient - 26 unit tests covering all mappers and DI registration Documentation: - ADR 003: Microsoft.Extensions.AI Integration - Feature doc: docs/Features/meai-integration.md - README: M.E.AI usage section with examples - Architecture overview updated with new module Closes managedcode#1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bc11f2f2a7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (userTextParts.Count > 0) | ||
| { | ||
| prompt.Append(string.Join("\n\n", userTextParts)); |
There was a problem hiding this comment.
Preserve message chronology when composing prompt
User text is collected into userTextParts and appended only after all messages are processed, while system/assistant text is appended immediately. In a normal history like User → Assistant → User, this reorders context so assistant output appears before the first user prompt, which can change model behavior and produce incorrect responses for IChatClient callers that pass full transcript history.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
| public CodexOptions? CodexOptions { get; init; } | ||
| public string? DefaultModel { get; init; } | ||
| public ThreadOptions? DefaultThreadOptions { get; init; } |
There was a problem hiding this comment.
Allow DI configuration delegate to set options
CodexChatClientOptions properties are init-only, but the DI extensions use an Action<CodexChatClientOptions> callback on an already-created instance. Consumers therefore cannot set DefaultModel/thread defaults inside AddCodexChatClient(...) configuration (assignments to init setters won't compile there), making the public configuration hook effectively non-functional.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
To use Codex here, create an environment for this repo.
Summary
Implements the
IChatClientadapter for CodexSharpSDK as a separate NuGet packageManagedCode.CodexSharpSDK.Extensions.AI, enabling standard M.E.AI consumer patterns (DI, middleware pipelines, provider-agnostic code).What's included
Design decisions
codex:*prefixed AdditionalProperties keysCloses #1