feat(maf): emit final response as result update - #11
Merged
Merged
Conversation
Surface the last agent message as a "result" AgentResponseUpdate right before the terminal event, and include it as a chat message in AgentResponse. On failures (turn.failed / thread error) the result carries the error message instead. Extend FakeCodexCli with failure injection and add tests covering the success, turn failure and thread error paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces the Codex agent's final response as a
resultupdate so consumers no longer have to reassemble streamed text to know the answer.RunStreamingAsyncnow emits aresultAgentResponseUpdateimmediately before the terminal update (turn.completed,turn.failedor threaderror). The update is intentionally not re-saving anything to chat history.RunAsyncappends the same final response as aresultchat message, so it is part ofAgentResponse.Messages.agent_messagewins on success;turn.failed/ thread error message wins otherwise).ThreadEventExtensions.CreateResultUpdatesetstype = "result",ChatRole.Assistant,AuthorName = "codex"and the normalized model name.Changes
src/CodexSdk.MAF/CodexAIAgent.cs— track the final response in both the streaming and non-streaming paths and emit/append it.src/CodexSdk.MAF/Internal/ThreadEventExtensions.cs— addCreateResultUpdate.tests/CodexSdk.MAF.Tests/CodexAIAgentResultUpdateTests.cs(new) — streaming/RunAsyncsuccess and failure coverage.tests/CodexSdk.MAF.Tests/ThreadEventExtensionsTests.cs— unit test forCreateResultUpdate.tests/FakeCodexCli/Program.cs— failure injection viaCODEX_TEST_FAILURE(turn,thread).tests/Support/FakeCodexCli.cs— exposeCreateOptions()and forward the failure mode.Verification
dotnet test: 47 passed, 0 failed (CodexSdk.Tests12,CodexSdk.MAF.Tests35).resultupdate is emitted, positioned directly beforeturn.completed, withRole = AssistantandAuthorName = codex.turn.failed("model unavailable") and threaderror("stream disconnected"), asserting the result text equals the error message in both the streaming andRunAsyncpaths.