[BREAKING] Python: Remove request_type param from ctx.request_info() (#1824)

* Remove request_type param from ctx.request_info()

* Address comments
This commit is contained in:
Tao Chen
2025-10-31 07:31:15 -07:00
committed by GitHub
Unverified
parent 2101d9d36d
commit 68b6a55757
21 changed files with 72 additions and 48 deletions
@@ -128,9 +128,8 @@ class Coordinator(Executor):
"Keep it under 30 words."
)
await ctx.request_info(
DraftFeedbackRequest(prompt=prompt, draft_text=draft_text, conversation=conversation),
DraftFeedbackRequest,
str,
request_data=DraftFeedbackRequest(prompt=prompt, draft_text=draft_text, conversation=conversation),
response_type=str,
)
@response_handler
@@ -76,7 +76,7 @@ class ReviewerWithHumanInTheLoop(Executor):
print("Reviewer: Escalating to human manager...")
# Forward the request to a human manager by sending a HumanReviewRequest.
await ctx.request_info(HumanReviewRequest(agent_request=request), HumanReviewRequest, ReviewResponse)
await ctx.request_info(request_data=HumanReviewRequest(agent_request=request), response_type=ReviewResponse)
@response_handler
async def accept_human_review(
@@ -125,13 +125,12 @@ class ReviewGateway(Executor):
await ctx.set_executor_state({"iteration": iteration, "last_draft": draft})
# Emit a human approval request.
await ctx.request_info(
HumanApprovalRequest(
request_data=HumanApprovalRequest(
prompt="Review the draft. Reply 'approve' or provide edit instructions.",
draft=draft,
iteration=iteration,
),
HumanApprovalRequest,
str,
response_type=str,
)
@response_handler
@@ -145,7 +145,7 @@ class DraftReviewRouter(Executor):
"Confirm CTA is action-oriented",
],
)
await ctx.request_info(request, ReviewRequest, str)
await ctx.request_info(request_data=request, response_type=str)
@response_handler
async def forward_decision(
@@ -251,7 +251,7 @@ class LaunchCoordinator(Executor):
await ctx.set_executor_state(executor_state)
# Send the request without modification
await ctx.request_info(review_request, ReviewRequest, str)
await ctx.request_info(request_data=review_request, response_type=str)
@response_handler
async def handle_request_response(
@@ -122,7 +122,7 @@ def build_resource_request_distribution_workflow() -> Workflow:
@handler
async def run(self, request: ResourceRequest, ctx: WorkflowContext) -> None:
await ctx.request_info(request, ResourceRequest, ResourceResponse)
await ctx.request_info(request_data=request, response_type=ResourceResponse)
@response_handler
async def handle_response(
@@ -136,7 +136,7 @@ def build_resource_request_distribution_workflow() -> Workflow:
@handler
async def run(self, request: PolicyRequest, ctx: WorkflowContext) -> None:
await ctx.request_info(request, PolicyRequest, PolicyResponse)
await ctx.request_info(request_data=request, response_type=PolicyResponse)
@response_handler
async def handle_response(
@@ -219,7 +219,7 @@ class ResourceAllocator(Executor):
else:
# Request cannot be fulfilled via cache, forward the request to external
self._pending_requests[request_payload.id] = source_event
await ctx.request_info(request_payload, ResourceRequest, ResourceResponse)
await ctx.request_info(request_data=request_payload, response_type=ResourceResponse)
@response_handler
async def handle_external_response(
@@ -270,7 +270,7 @@ class PolicyEngine(Executor):
else:
# For other policy types, forward to external system
self._pending_requests[request_payload.id] = source_event
await ctx.request_info(request_payload, PolicyRequest, PolicyResponse)
await ctx.request_info(request_data=request_payload, response_type=PolicyResponse)
@response_handler
async def handle_external_response(
@@ -124,7 +124,7 @@ def build_email_address_validation_workflow() -> Workflow:
print(f"🔍 Validating domain: '{domain}'")
self._pending_domains[domain] = partial_result
# Send a request to the external system via the request_info mechanism
await ctx.request_info(domain, str, bool)
await ctx.request_info(request_data=domain, response_type=bool)
@response_handler
async def handle_domain_validation_response(
@@ -115,7 +115,6 @@ class TurnManager(Executor):
# Send a request with a prompt as the payload and expect a string reply.
await ctx.request_info(
request_data=HumanFeedbackRequest(prompt=prompt),
request_type=HumanFeedbackRequest,
response_type=str,
)