.NET: Add declarative HttpRequestAction support to workflows#5474
.NET: Add declarative HttpRequestAction support to workflows#5474
Conversation
There was a problem hiding this comment.
Pull request overview
Adds .NET declarative workflow support for HttpRequestAction, enabling workflow authors to make HTTP calls from YAML and bind response body/headers into workflow state and/or conversation messages.
Changes:
- Adds
IHttpRequestHandlerplus aDefaultHttpRequestHandler(HttpClient-based) implementation. - Wires
HttpRequestActioninto the interpreter via a newHttpRequestExecutorandDeclarativeWorkflowOptions.HttpRequestHandler. - Adds unit + integration test coverage and example workflows for declarative HTTP execution.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/IHttpRequestHandler.cs | Introduces the HTTP handler abstraction and request/response DTOs. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DefaultHttpRequestHandler.cs | Provides the default HttpClient-backed implementation. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowOptions.cs | Adds HttpRequestHandler option required for HttpRequestAction execution. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowActionVisitor.cs | Enables HttpRequestAction execution and validates handler configuration. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/HttpRequestExecutor.cs | Executes the declarative HTTP request and assigns body/headers into workflow state and/or conversation. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Workflows/HttpRequest.yaml | Adds a unit-test workflow exercising declarative HTTP action parsing/execution. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/HttpRequestExecutorTest.cs | Adds unit tests for executor request formation, parsing, state assignment, and conversation output. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DefaultHttpRequestHandlerTests.cs | Adds unit tests for DefaultHttpRequestHandler request mapping, headers, query params, timeouts, disposal. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs | Extends workflow test harness to provide an HTTP handler and adds HttpRequest workflow cases. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Workflows/HttpRequest.yaml | Adds an integration workflow that calls GitHub API and surfaces a parsed field. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/InvokeToolWorkflowTest.cs | Adds integration test runner for HttpRequestAction workflows. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Framework/IntegrationTest.cs | Extends options factory to accept an IHttpRequestHandler. |
| dotnet/agent-framework-dotnet.slnx | Reorders a few solution entries (no functional impact). |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 3 | Confidence: 90%
✓ Correctness
This PR adds HTTP request support to declarative workflows by introducing IHttpRequestHandler/DefaultHttpRequestHandler abstractions and an HttpRequestExecutor. The implementation correctly follows the established visitor pattern (matching the InvokeMcpTool precedent), has proper timeout handling via linked CancellationTokenSource, correct error categorization distinguishing timeout from external cancellation, and safe JSON parsing that materializes data before disposing JsonDocument. The overload chain in the integration test base class is correctly wired. Tests are comprehensive, covering success/failure paths, timeout, headers, query parameters, body content types, and conversation integration. No significant correctness issues found.
✓ Security Reliability
This PR adds HTTP request support to declarative workflows via IHttpRequestHandler, DefaultHttpRequestHandler, and HttpRequestExecutor. The implementation follows established patterns (mirroring IMcpToolHandler/InvokeMcpToolExecutor), has proper resource management (using statements on HttpRequestMessage, HttpResponseMessage, CancellationTokenSource), correct timeout handling via linked CancellationTokenSource, and good input validation. The handler is opt-in, requiring explicit configuration. Query parameter values are properly escaped with Uri.EscapeDataString. The code is well-structured with comprehensive unit tests. No blocking security or reliability issues were found.
✗ Design Approach
The runtime wiring for
HttpRequestActionis in place, but the design is still incomplete in two important ways. First, the executor hard-codes all non-2xx responses into exceptions instead of honoring the action’s own error-handling contract, which turns HTTP status handling into an exception-only mechanism. Second, the PR updates the interpreted execution path only; code generation still treatsHttpRequestActionas unsupported, so generated/ejected workflows will diverge from runtime behavior.
Suggestions
- WorkflowActionVisitor.cs:531 adds runtime support for
HttpRequestAction, but WorkflowTemplateVisitor.cs:414 still marks it unsuported. If this action is now supported, update the Eject/codegen path in the same change so interpreted and generated workflows stay aligned.
Automated review by peibekwe's agents
Description
Adds end-to-end support for the declarative
HttpRequestActionso workflow authors can issue HTTP requests directly from YAML and pipe responses into variables or the conversation. Mirrors the shape ofInvokeFunctionTool/InvokeMcpTool.Contribution Checklist