Certainly! Based on your detailed example for the ConsumerHealthAgent class, I have rewritten your original TariffTradeAgent class to follow the same style, detailed structure, and formatting approach, with the specific new prompt you requested for US Politics / Tariffs, each prompt fully self-contained with clear instructions and formatting rules.
Here is the updated TariffTradeAgent class fully adapted in the style of your example:
from agents.base_agent import BaseAgent
class TariffTradeAgent(BaseAgent):
prompt_sys = "Tariff and trade policy analyst for Macy's CEO works for only provided documents"
# Universal formatting enforcement line
formatting_directive = """Please strictly follow these formatting guidelines for all numerical mentions and sentence structures:
1. **No Combined Elements**: Always space-separate numbers, words, and units (e.g., "3.3 billion" not "3.3billion").
2. **Time Formatting**: Use formats like "Q4 2024" (never "Q42024" or "4th quarter").
3. **Number Rules**:
- 3.3B → 3.3 billion
- 150.2M → 150.2 million
- 0.33 → keep exact decimal
4. **Text Integrity**:
- "net income" never "netincome"
- "year-over-year" never "YOY" or "yearoveryear"
5. **Style Prohibition**: Do not italicize or alter text formatting; maintain a single plain format throughout.
6. **Bad Example**: `3.3billioninQ42024,withanadjustednetincomeof,106million,withadjustedearningsperdilutedshareat0.95` → REJECTED
7. **ALWAYS Required Format**: `3.3 billion in Q4 2024, with an adjusted net income of` → ACCEPTED
APPLY THESE RULES TO ALL NUMERICAL MENTIONS AND SENTENCE STRUCTURES."""
prompt_analyze = (
"Summarize how the company spoke to tariff impact. Lead with any country or regional sourcing exposure, if applicable. Then also provide any quantitative financial impact, if applicable. Finally, provide the mitigation actions it has either already implemented or is planning to implement, including changes to pricing. If no detail is provided, say “N/A”.\n\n"
"The output should be a summary of the commentary, in 100 words or less. The summary should be in the third person (name of the company, management, the company).\n\n"
"For every topic, ALWAYS provide excerpts mentioned under the heading \"Ground Truth\" as follows:\n"
"- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n"
"- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n"
"- If a topic is present in multiple documents, include a separate \"Ground Truth\" excerpt for each document.\n"
"- Do NOT paraphrase, summarize, or alter the original text in any way. The excerpt must match the source exactly, including all formatting, punctuation, and special characters.\n"
"- If the LLM cannot find an exact match in the document, do NOT fabricate or modify the excerpt—only include what is present in the document.\n\n"
"Format the output as a concise summary without recommendations.\n\n"
"Document Text: " + formatting_directive
)
prompt_summary = (
"You are a senior tariff and trade analyst preparing a consolidated tariff and trade policy report for Macy's executive team from all documents provided.\n\n"
"Identify and describe all impactful tariff, trade, and related government policy topics across the documents provided that could affect Macy's business operations including supply chain, procurement, retail sales, and technology.\n\n"
"For each topic:\n"
"- Provide a concise summary by combining relevant information from the documents.\n"
"- Include relevant financial impacts, examples, figures, or timelines.\n"
"- Provide three to five actionable strategic recommendations based on the analysis.\n\n"
"For every topic, ALWAYS provide each excerpt mentioned under the heading \"Ground Truth\" as follows:\n"
"- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n"
"- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n"
"- If a topic is in multiple documents, include separate excerpts for each document with proper line breaks.\n"
"- Do NOT paraphrase or alter any text.\n"
"- If no exact excerpts are found, do NOT fabricate or modify content.\n\n"
"Format the report in clear markdown with sections:\n"
"- Executive Summary\n"
"- Key Themes\n"
"- Strategic Recommendations\n"
"- Risk Assessment\n\n"
"STRICTLY enforce plain text formatting:\n"
+ formatting_directive
)
prompt_detail = (
"You are preparing a detailed briefing for Macy's CEO on the tariff and trade policy topic '{topic}', based on the provided external company document.\n\n"
"Provide:\n"
"1. A clear overview of the topic.\n"
"2. Key insights and relevant excerpts.\n"
"3. Important figures, dates, or timelines if available.\n"
"4. A detailed analysis on how this topic could impact Macy's retail operations, supply chain, procurement, and consumer behavior.\n"
"5. Three to five actionable strategic recommendations for Macy's leadership.\n\n"
"For every topic, ALWAYS provide verbatim source excerpts under the heading \"Ground Truth\" as follows:\n"
"- For each document where the topic appears, extract the exact, unmodified sentence(s) or paragraph(s) from the original document.\n"
"- Format each excerpt as: **Ground Truth:** \"Exact text from the document...\" (Document Name)\n"
"- If a topic is present in multiple documents, include a separate excerpt for each.\n"
"- Do NOT paraphrase, summarize, or alter the text.\n"
"- If no exact excerpts exist, do NOT fabricate or modify content.\n\n"
"Document:\n"
"{text}\n\n"
"Topic: {topic}\n\n"
"Please provide a structured briefing with clear paragraphs and bold topics.\n"
+ formatting_directive
)
def analyze_document(self, text, custom_prompt=None):
prompt_analyze = custom_prompt if custom_prompt else self.prompt_analyze
return super().analyze_document(self.prompt_sys, prompt_analyze, text)
def generate_consolidated_summary_from_topics(self, processed_files, custom_prompt=None):
prompt_summary = custom_prompt if custom_prompt else self.prompt_summary
return super().generate_consolidated_summary_from_topics(self.prompt_sys, prompt_summary, processed_files)
def generate_topic_detail(self, text, topic, custom_prompt=None):
prompt_detail = custom_prompt if custom_prompt else self.prompt_detail
return super().generate_topic_detail(self.prompt_sys, prompt_detail, text, topic)
Summary of changes / style notes:
- prompt_sys: unchanged.
- formatting_directive: very detailed and strict, adapted to your style.
- prompt_analyze now matches your requested US Politics / Tariff style exactly, with instructions for short, third-person summaries, and sample instructions for ground-truth excerpts.
- Added detailed instructions for excerpts under "Ground Truth" instead of just "Source Truth" for consistency with your example.
- prompt_summary and prompt_detail are likewise rewritten to match the verbose, bullet/numbered format, focus on structured markdown output with clear headings, and strict formatting directives.
- All prompt strings accept multi-line formatting, clear instructions, and follow your example of layered detail.
If you want me to adjust anything further or adapt this into multiple agents/classes similarly, just ask!