Skip to content

Implement fallback draft generation in AuthorAgent and add unit tests… - #24

Merged
JesseLiberty merged 1 commit into
mainfrom
FixOutput
Sep 5, 2026
Merged

Implement fallback draft generation in AuthorAgent and add unit tests…#24
JesseLiberty merged 1 commit into
mainfrom
FixOutput

Conversation

@JesseLiberty

Copy link
Copy Markdown
Owner

… for draft handling

Copilot AI lite review requested due to automatic review settings September 5, 2026 15:28
@JesseLiberty
JesseLiberty merged commit d8355d6 into main Sep 5, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new empty-draft handling can still treat whitespace-only model output as a valid draft, which can leave an effectively empty/unreviewable draft unless the checks are tightened.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR ensures the Author stage always leaves the workflow with a reviewable draft by generating a fallback draft when the model returns no content and no prior draft exists, and adds unit tests to validate this behavior.

Changes:

  • Add fallback draft generation in AuthorAgent.AuthorNodeAsync when the model output is empty and state.Draft is also empty.
  • Add EmptyChatClient test double to simulate a model returning an empty response.
  • Add AuthorAgentTests to cover fallback behavior, keeping an existing draft, and using model-generated content.
File summaries
File Description
AuthorAgent.cs Adds last-resort fallback draft construction when no draft can be generated or retained.
BlogWriter.Tests/TestChatClients.cs Adds EmptyChatClient to simulate empty model responses in tests.
BlogWriter.Tests/AuthorAgentTests.cs Adds unit tests validating fallback and non-clobbering behavior in the author stage.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread AuthorAgent.cs
Comment on lines 106 to +109
if (string.IsNullOrEmpty(draft))
{
// Keep whatever draft already exists rather than clobbering it with a
// placeholder — an empty/failed generation shouldn't erase real content.
_logger.LogWarning("Author agent produced no draft; keeping the previous draft (if any).");
if (string.IsNullOrEmpty(state.Draft))
{

state = await CreateAgent(new EmptyChatClient()).AuthorNodeAsync(state);

Assert.False(string.IsNullOrEmpty(state.Draft));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants