Building AI agents, atomically
style: flake8 — rename `l` → `learning`, wrap long writer prompt line
KennyVaneetveldea11726ff4b7b
diff --git a/atomic-examples/deep-research/deep_research/agents/writer_agent.py b/atomic-examples/deep-research/deep_research/agents/writer_agent.pyindex 355e554..9750fff 100644--- a/atomic-examples/deep-research/deep_research/agents/writer_agent.py+++ b/atomic-examples/deep-research/deep_research/agents/writer_agent.py@@ -71,7 +71,8 @@ writer_agent = AtomicAgent[WriterInput, WriterOutput](" 1. Read the research state (sources and learnings) from the system context."," 2. Organise the report with one section per sub-topic, in a logical order."," 3. Every factual sentence cites the source(s) it's based on using [S1] / [S2, S4] markers.",- " 4. End with a '## Sources' section. Format each entry as a bullet list: `- [Sn]: <title> — <url>`. Do NOT append a trailing [Sn] after the URL.",+ " 4. End with a '## Sources' section. Format each entry as "+ "`- [Sn]: <title> — <url>`. Do NOT append a trailing [Sn] after the URL.","In 'verify' mode:"," 1. Read the draft provided in the input."," 2. Remove any sentence that carries a citation marker not present in the research state's sources.",diff --git a/atomic-examples/deep-research/deep_research/context_providers.py b/atomic-examples/deep-research/deep_research/context_providers.pyindex 0c6cb05..56d644d 100644--- a/atomic-examples/deep-research/deep_research/context_providers.py+++ b/atomic-examples/deep-research/deep_research/context_providers.py@@ -42,13 +42,13 @@ class ResearchStateProvider(BaseDynamicContextProvider):lines.append("")lines.append("### Learnings so far (grouped by sub-topic)")seen_topics: list[str] = []- for l in self.state.learnings:- if l.sub_topic not in seen_topics:- seen_topics.append(l.sub_topic)+ for learning in self.state.learnings:+ if learning.sub_topic not in seen_topics:+ seen_topics.append(learning.sub_topic)for sub_topic in seen_topics:lines.append(f"**{sub_topic}**")- for l in self.state.learnings_for(sub_topic):- lines.append(f"- {l.text} [{l.source_id}]")+ for learning in self.state.learnings_for(sub_topic):+ lines.append(f"- {learning.text} [{learning.source_id}]")return "\n".join(lines)diff --git a/atomic-examples/deep-research/deep_research/state.py b/atomic-examples/deep-research/deep_research/state.pyindex 01f4f84..817c222 100644--- a/atomic-examples/deep-research/deep_research/state.py+++ b/atomic-examples/deep-research/deep_research/state.py@@ -65,7 +65,7 @@ class ResearchState:started_at: datetime = field(default_factory=datetime.utcnow)def learnings_for(self, sub_topic: str) -> list[Learning]:- return [l for l in self.learnings if l.sub_topic == sub_topic]+ return [learning for learning in self.learnings if learning.sub_topic == sub_topic]def register_source(self, url: str, title: str) -> Source:"""Register a source if new, return the (new or existing) record.