Python: [BREAKING] update to v1.0.0 (#5062)

* updates to final deprecated pieces and versions

* fix mypy

* fix readme links
This commit is contained in:
Eduard van Valkenburg
2026-04-02 17:26:30 +02:00
committed by GitHub
Unverified
parent 5f06b68535
commit 3446eb8d5d
171 changed files with 2580 additions and 2392 deletions
@@ -149,7 +149,10 @@ class Coordinator(Executor):
# Human approved the draft as-is; forward it unchanged.
await ctx.send_message(
AgentExecutorRequest(
messages=[*original_request.conversation, *[Message("user", text="The draft is approved as-is.")]],
messages=[
*original_request.conversation,
*[Message("user", contents=["The draft is approved as-is."])],
],
should_respond=True,
),
target_id=self.final_editor_id,
@@ -164,7 +167,7 @@ class Coordinator(Executor):
"Keep the response under 120 words and reflect any requested tone adjustments."
)
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=instruction)], should_respond=True),
AgentExecutorRequest(messages=[Message("user", contents=[instruction])], should_respond=True),
target_id=self.writer_id,
)
@@ -84,15 +84,17 @@ class Reviewer(Executor):
messages = [
Message(
role="system",
text=(
"You are a reviewer for an AI agent. Provide feedback on the "
"exchange between a user and the agent. Indicate approval only if:\n"
"- Relevance: response addresses the query\n"
"- Accuracy: information is correct\n"
"- Clarity: response is easy to understand\n"
"- Completeness: response covers all aspects\n"
"Do not approve until all criteria are satisfied."
),
contents=[
(
"You are a reviewer for an AI agent. Provide feedback on the "
"exchange between a user and the agent. Indicate approval only if:\n"
"- Relevance: response addresses the query\n"
"- Accuracy: information is correct\n"
"- Clarity: response is easy to understand\n"
"- Completeness: response covers all aspects\n"
"Do not approve until all criteria are satisfied."
)
],
)
]
# Add conversation history.
@@ -97,7 +97,7 @@ class BriefPreparer(Executor):
# Hand the prompt to the writer agent. We always route through the
# workflow context so the runtime can capture messages for checkpointing.
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=prompt)], should_respond=True),
AgentExecutorRequest(messages=[Message("user", contents=[prompt])], should_respond=True),
target_id=self._agent_id,
)
@@ -159,7 +159,7 @@ class ReviewGateway(Executor):
f"Human guidance: {reply}"
)
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=prompt)], should_respond=True),
AgentExecutorRequest(messages=[Message("user", contents=[prompt])], should_respond=True),
target_id=self._writer_id,
)
@@ -129,7 +129,7 @@ async def to_email_assistant_request(
"""
# Bridge executor. Converts a structured DetectionResult into a Message and forwards it as a new request.
detection = DetectionResult.model_validate_json(response.agent_response.text)
user_msg = Message("user", text=detection.email_content)
user_msg = Message("user", contents=[detection.email_content])
await ctx.send_message(AgentExecutorRequest(messages=[user_msg], should_respond=True))
@@ -200,7 +200,7 @@ async def main() -> None:
# Execute the workflow. Since the start is an AgentExecutor, pass an AgentExecutorRequest.
# The workflow completes when it becomes idle (no more work to do).
request = AgentExecutorRequest(messages=[Message("user", text=email)], should_respond=True)
request = AgentExecutorRequest(messages=[Message("user", contents=[email])], should_respond=True)
events = await workflow.run(request)
outputs = events.get_outputs()
if outputs:
@@ -97,7 +97,7 @@ async def store_email(email_text: str, ctx: WorkflowContext[AgentExecutorRequest
ctx.set_state(CURRENT_EMAIL_ID_KEY, new_email.email_id)
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=new_email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[new_email.email_content])], should_respond=True)
)
@@ -124,7 +124,7 @@ async def submit_to_email_assistant(analysis: AnalysisResult, ctx: WorkflowConte
email: Email = ctx.get_state(f"{EMAIL_STATE_PREFIX}{analysis.email_id}")
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[email.email_content])], should_respond=True)
)
@@ -139,7 +139,7 @@ async def summarize_email(analysis: AnalysisResult, ctx: WorkflowContext[AgentEx
# Only called for long NotSpam emails by selection_func
email: Email = ctx.get_state(f"{EMAIL_STATE_PREFIX}{analysis.email_id}")
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[email.email_content])], should_respond=True)
)
@@ -102,7 +102,7 @@ class SubmitToJudgeAgent(Executor):
f"Target: {self._target}\nGuess: {guess}\nResponse:"
)
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=prompt)], should_respond=True),
AgentExecutorRequest(messages=[Message("user", contents=[prompt])], should_respond=True),
target_id=self._judge_agent_id,
)
@@ -104,7 +104,7 @@ async def store_email(email_text: str, ctx: WorkflowContext[AgentExecutorRequest
# Kick off the detector by forwarding the email as a user message to the spam_detection_agent.
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=new_email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[new_email.email_content])], should_respond=True)
)
@@ -125,7 +125,7 @@ async def submit_to_email_assistant(detection: DetectionResult, ctx: WorkflowCon
# Load the original content from workflow state using the id carried in DetectionResult.
email: Email = ctx.get_state(f"{EMAIL_STATE_PREFIX}{detection.email_id}")
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[email.email_content])], should_respond=True)
)
@@ -103,7 +103,8 @@ class Coordinator(Executor):
# Human approved the draft as-is; forward it unchanged.
await ctx.send_message(
AgentExecutorRequest(
messages=original_request.conversation + [Message("user", text="The draft is approved as-is.")],
messages=original_request.conversation
+ [Message("user", contents=["The draft is approved as-is."])],
should_respond=True,
),
target_id=self.final_editor_name,
@@ -118,7 +119,7 @@ class Coordinator(Executor):
"Rewrite the draft from the previous assistant message into a polished final version. "
"Keep the response under 120 words and reflect any requested tone adjustments."
)
conversation.append(Message("user", text=instruction))
conversation.append(Message("user", contents=[instruction]))
await ctx.send_message(
AgentExecutorRequest(messages=conversation, should_respond=True),
target_id=self.writer_name,
@@ -85,13 +85,15 @@ async def aggregate_with_synthesis(results: list[AgentExecutorResponse]) -> Any:
system_msg = Message(
"system",
text=(
"You are a synthesis expert. Consolidate the following analyst perspectives "
"into one cohesive, balanced summary (3-4 sentences). If human guidance is provided, "
"prioritize aspects as directed."
),
contents=[
(
"You are a synthesis expert. Consolidate the following analyst perspectives "
"into one cohesive, balanced summary (3-4 sentences). If human guidance is provided, "
"prioritize aspects as directed."
)
],
)
user_msg = Message("user", text="\n\n".join(expert_sections) + guidance_text)
user_msg = Message("user", contents=["\n\n".join(expert_sections) + guidance_text])
response = await _chat_client.get_response([system_msg, user_msg])
return response.messages[-1].text if response.messages else ""
@@ -91,7 +91,7 @@ class TurnManager(Executor):
- Input is a simple starter token (ignored here).
- Output is an AgentExecutorRequest that triggers the agent to produce a guess.
"""
user = Message("user", text="Start by making your first guess.")
user = Message("user", contents=["Start by making your first guess."])
await ctx.send_message(AgentExecutorRequest(messages=[user], should_respond=True))
@handler
@@ -150,7 +150,7 @@ class TurnManager(Executor):
f"Feedback: {reply}. Your last guess was {last_guess}. "
f"Use this feedback to adjust and make your next guess (1-10)."
)
user_msg = Message("user", text=feedback_text)
user_msg = Message("user", contents=[feedback_text])
await ctx.send_message(AgentExecutorRequest(messages=[user_msg], should_respond=True))
@@ -82,12 +82,14 @@ async def main() -> None:
# Ask the model to synthesize a concise summary of the experts' outputs
system_msg = Message(
"system",
text=(
"You are a helpful assistant that consolidates multiple domain expert outputs "
"into one cohesive, concise summary with clear takeaways. Keep it under 200 words."
),
contents=[
(
"You are a helpful assistant that consolidates multiple domain expert outputs "
"into one cohesive, concise summary with clear takeaways. Keep it under 200 words."
)
],
)
user_msg = Message("user", text="\n\n".join(expert_sections))
user_msg = Message("user", contents=["\n\n".join(expert_sections)])
response = await client.get_response([system_msg, user_msg])
# Return the model's final assistant text as the completion result
@@ -49,7 +49,7 @@ class DispatchToExperts(Executor):
@handler
async def dispatch(self, prompt: str, ctx: WorkflowContext[AgentExecutorRequest]) -> None:
# Wrap the incoming prompt as a user message for each expert and request a response.
initial_message = Message("user", text=prompt)
initial_message = Message("user", contents=[prompt])
await ctx.send_message(AgentExecutorRequest(messages=[initial_message], should_respond=True))
@@ -109,7 +109,7 @@ async def store_email(email_text: str, ctx: WorkflowContext[AgentExecutorRequest
ctx.set_state(CURRENT_EMAIL_ID_KEY, new_email.email_id)
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=new_email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[new_email.email_content])], should_respond=True)
)
@@ -140,7 +140,7 @@ async def submit_to_email_assistant(detection: DetectionResult, ctx: WorkflowCon
# Load the original content by id from workflow state and forward it to the assistant.
email: Email = ctx.get_state(f"{EMAIL_STATE_PREFIX}{detection.email_id}")
await ctx.send_message(
AgentExecutorRequest(messages=[Message("user", text=email.email_content)], should_respond=True)
AgentExecutorRequest(messages=[Message("user", contents=[email.email_content])], should_respond=True)
)
@@ -46,7 +46,7 @@ class DispatchToExperts(Executor):
@handler
async def dispatch(self, prompt: str, ctx: WorkflowContext[AgentExecutorRequest]) -> None:
# Wrap the incoming prompt as a user message for each expert and request a response.
initial_message = Message("user", text=prompt)
initial_message = Message("user", contents=[prompt])
await ctx.send_message(AgentExecutorRequest(messages=[initial_message], should_respond=True))