From 102bd5154103d176fb7837c81216dea968b2e20e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 24 Aug 2026 10:28:27 +0000 Subject: [PATCH] docs: pass validated structured notes in isolation example Use response_format and result.pydantic so the Flow handoff is OutreachNotes, not a raw string dump. Co-authored-by: Rip&Tear --- .../ar/guides/agents/secure-agent-design.mdx | 22 ++++++++++++++----- .../en/guides/agents/secure-agent-design.mdx | 22 ++++++++++++++----- .../ko/guides/agents/secure-agent-design.mdx | 22 ++++++++++++++----- .../guides/agents/secure-agent-design.mdx | 22 ++++++++++++++----- 4 files changed, 68 insertions(+), 20 deletions(-) diff --git a/docs/edge/ar/guides/agents/secure-agent-design.mdx b/docs/edge/ar/guides/agents/secure-agent-design.mdx index 80941c2c4..dc52cc4ae 100644 --- a/docs/edge/ar/guides/agents/secure-agent-design.mdx +++ b/docs/edge/ar/guides/agents/secure-agent-design.mdx @@ -293,24 +293,36 @@ analyst = Agent( from crewai.flow.flow import Flow, listen, start from pydantic import BaseModel +class OutreachNotes(BaseModel): + claims: list[str] + sources: list[str] + class PipelineState(BaseModel): topic: str = "" - notes: list[str] = [] + notes: OutreachNotes | None = None email_status: str = "" class SecureOutreachFlow(Flow[PipelineState]): @start() def research(self): result = researcher.kickoff( - f"Extract factual notes about {self.state.topic}." + f"Extract factual notes about {self.state.topic}.", + response_format=OutreachNotes, ) - self.state.notes = [result.raw] + notes = result.pydantic + if not isinstance(notes, OutreachNotes) or not notes.claims or not notes.sources: + raise ValueError("Research must return validated OutreachNotes.") + self.state.notes = notes @listen(research) def send(self): - approved = "\n".join(self.state.notes) + notes = self.state.notes + if notes is None: + raise ValueError("No validated notes to send.") result = sender.kickoff( - f"Send outreach using only these notes:\n{approved}" + "Send outreach using only these claims and sources:\n" + f"claims={notes.claims}\n" + f"sources={notes.sources}" ) self.state.email_status = result.raw ``` diff --git a/docs/edge/en/guides/agents/secure-agent-design.mdx b/docs/edge/en/guides/agents/secure-agent-design.mdx index ee910adef..7d5e455f5 100644 --- a/docs/edge/en/guides/agents/secure-agent-design.mdx +++ b/docs/edge/en/guides/agents/secure-agent-design.mdx @@ -293,24 +293,36 @@ analyst = Agent( from crewai.flow.flow import Flow, listen, start from pydantic import BaseModel +class OutreachNotes(BaseModel): + claims: list[str] + sources: list[str] + class PipelineState(BaseModel): topic: str = "" - notes: list[str] = [] + notes: OutreachNotes | None = None email_status: str = "" class SecureOutreachFlow(Flow[PipelineState]): @start() def research(self): result = researcher.kickoff( - f"Extract factual notes about {self.state.topic}." + f"Extract factual notes about {self.state.topic}.", + response_format=OutreachNotes, ) - self.state.notes = [result.raw] + notes = result.pydantic + if not isinstance(notes, OutreachNotes) or not notes.claims or not notes.sources: + raise ValueError("Research must return validated OutreachNotes.") + self.state.notes = notes @listen(research) def send(self): - approved = "\n".join(self.state.notes) + notes = self.state.notes + if notes is None: + raise ValueError("No validated notes to send.") result = sender.kickoff( - f"Send outreach using only these notes:\n{approved}" + "Send outreach using only these claims and sources:\n" + f"claims={notes.claims}\n" + f"sources={notes.sources}" ) self.state.email_status = result.raw ``` diff --git a/docs/edge/ko/guides/agents/secure-agent-design.mdx b/docs/edge/ko/guides/agents/secure-agent-design.mdx index d8e50bda2..a5ce9d125 100644 --- a/docs/edge/ko/guides/agents/secure-agent-design.mdx +++ b/docs/edge/ko/guides/agents/secure-agent-design.mdx @@ -293,24 +293,36 @@ analyst = Agent( from crewai.flow.flow import Flow, listen, start from pydantic import BaseModel +class OutreachNotes(BaseModel): + claims: list[str] + sources: list[str] + class PipelineState(BaseModel): topic: str = "" - notes: list[str] = [] + notes: OutreachNotes | None = None email_status: str = "" class SecureOutreachFlow(Flow[PipelineState]): @start() def research(self): result = researcher.kickoff( - f"Extract factual notes about {self.state.topic}." + f"Extract factual notes about {self.state.topic}.", + response_format=OutreachNotes, ) - self.state.notes = [result.raw] + notes = result.pydantic + if not isinstance(notes, OutreachNotes) or not notes.claims or not notes.sources: + raise ValueError("Research must return validated OutreachNotes.") + self.state.notes = notes @listen(research) def send(self): - approved = "\n".join(self.state.notes) + notes = self.state.notes + if notes is None: + raise ValueError("No validated notes to send.") result = sender.kickoff( - f"Send outreach using only these notes:\n{approved}" + "Send outreach using only these claims and sources:\n" + f"claims={notes.claims}\n" + f"sources={notes.sources}" ) self.state.email_status = result.raw ``` diff --git a/docs/edge/pt-BR/guides/agents/secure-agent-design.mdx b/docs/edge/pt-BR/guides/agents/secure-agent-design.mdx index c5017f2e1..71a109e43 100644 --- a/docs/edge/pt-BR/guides/agents/secure-agent-design.mdx +++ b/docs/edge/pt-BR/guides/agents/secure-agent-design.mdx @@ -293,24 +293,36 @@ analyst = Agent( from crewai.flow.flow import Flow, listen, start from pydantic import BaseModel +class OutreachNotes(BaseModel): + claims: list[str] + sources: list[str] + class PipelineState(BaseModel): topic: str = "" - notes: list[str] = [] + notes: OutreachNotes | None = None email_status: str = "" class SecureOutreachFlow(Flow[PipelineState]): @start() def research(self): result = researcher.kickoff( - f"Extract factual notes about {self.state.topic}." + f"Extract factual notes about {self.state.topic}.", + response_format=OutreachNotes, ) - self.state.notes = [result.raw] + notes = result.pydantic + if not isinstance(notes, OutreachNotes) or not notes.claims or not notes.sources: + raise ValueError("Research must return validated OutreachNotes.") + self.state.notes = notes @listen(research) def send(self): - approved = "\n".join(self.state.notes) + notes = self.state.notes + if notes is None: + raise ValueError("No validated notes to send.") result = sender.kickoff( - f"Send outreach using only these notes:\n{approved}" + "Send outreach using only these claims and sources:\n" + f"claims={notes.claims}\n" + f"sources={notes.sources}" ) self.state.email_status = result.raw ```