How to Build a Practical Agent with Automation Workflows
This article walks through building a practical automation workflow that doubles as the foundation for an AI agent: a scheduled pipeline that collects multiple information sources, generates a structured summary with a large language model, and pushes the result to a team channel. It covers the four-stage architecture (trigger, collection, generation, distribution), why collection and generation should be decoupled, collection principles that favor stability over coverage, treating prompts as version-controlled code, delivery retries and audit trails, common pitfalls such as duplicate pushes and cost overruns, and how the same skeleton extends to broader agent workflows with limited decision-making.
1. Background: Why “Daily Information Digest” Is Worth Automating
Across engineering, product, and marketing teams, one class of work is high-frequency, repetitive, and hard to skip: every morning, scan a handful of information sources, filter out the noise, extract the key points, and post them to the team chat. A single run takes only fifteen to twenty minutes, but three characteristics make it an ideal automation target:
- Clear rules: the input is a fixed set of sources, the output is a summary in a fixed format, and the steps in between can be broken down cleanly.
- Stable value: the team has a continuous need for “someone to consolidate the key points every day”; it does not depend on occasional inspiration.
- Bounded blast radius: even if the summary quality is mediocre on a given day, the loss is one morning of delayed information, not a production incident.
Scenarios like this are among the best entry points for automation workflows and agent capabilities. This article uses “scheduled multi-source collection + LLM-generated summary + push to the team channel” as the main thread and lays out a reproducible, extensible, and maintainable technical approach.
2. Overall Architecture: A Scheduled Four-Stage Pipeline
The whole solution abstracts into four stages, all driven by a scheduler:
- Trigger layer: emits an execution event on a fixed schedule (for example, the same time daily), with timezone support and manual backfill.
- Collection layer: fetches multiple sources concurrently, with timeout control and content normalization.
- Generation layer: after cleaning and deduplication, calls the LLM with a fixed template to produce a structured summary.
- Distribution layer: formats the result, pushes it to the team communication tool, and persists it for traceability.
An illustrative flow description (pseudocode, meant to express orchestration logic rather than a specific product API):
schedule(daily_at("08:00", tz="Asia/Shanghai"))-> fetch_all(sources, timeout=10s, concurrency=5)-> normalize_and_dedupe(items, since=last_success_time)-> llm_summarize(items, template=BRIEF_TEMPLATE, max_words=300)-> render_markdown(result)-> push_to_group(channel="daily-brief")-> persist_run_log(result, status)
The key design decision here is decoupling collection from generation. A collection failure should only affect that day’s data completeness and must not block the entire pipeline; a generation failure should trigger retries and a fallback strategy rather than silently dropping the message.
3. Collection Layer: Stability Over Coverage
Collection is the most failure-prone stage. Four principles are worth following:
- Timeouts and concurrency caps: a per-source timeout of 8–12 seconds and overall concurrency around 5 help avoid being rate-limited by the other side.
- Incremental fetching: record the timestamp watermark of the last successful run and process only new items. This reduces model calls and prevents duplicate pushes.
- Content normalization: convert everything into a five-field tuple of
title / source / published_at / summary / url, with fallback values for missing fields so template rendering does not break later. - Failure isolation: an exception on a single source is logged and the run is marked “partially successful”; the missing sources are noted in the pushed content to keep the information transparent.
{"title": "Example item title","source": "source_1","published_at": "2026-08-26T06:30:00+08:00","summary": "First 200 characters of the body, plain text with scripts and styles removed","url": "https://example.invalid/item/1"}
4. Generation Layer: Treat the Prompt as Managed Code
Summary quality depends almost entirely on the prompt and how context is organized. Keep prompts under version control and make the following explicit:
- Role and goal: you are a senior industry analysis assistant producing a morning brief for an engineering team.
- Input constraints: use only the provided items, introduce no outside knowledge; when information is insufficient, write “no further information available.”
- Output structure: one summary sentence first, then 3–5 key points grouped by topic, each no longer than 40 characters.
- Length control: about 300 characters in total, counted as Chinese characters.
- Prohibitions: no disclaimers, no repeating source names, no exaggerated adjectives.
A reusable template skeleton:
You are a senior industry analysis assistant. Generate a morning brief from the items below:1) One summary sentence (no more than 30 characters)2) 3-5 key points ordered by importance, each no more than 40 characters3) End with the total item count and source countConstraints: use only the provided content; write "no further information available" when there is none; total length about 300 characters.Item list: {{items}}
In practice, assign a version number to each prompt and log the version used on every run. When output quality fluctuates, you can roll back to the last stable version quickly instead of relying on trial and error.
5. Distribution and Traceability: Make Automation Auditable
The push step is often overlooked, yet it determines whether the team trusts the pipeline long term:
- Format adaptation: group messages have limited support for tables and long links, so prefer short points and bulleted lists.
- Retry on failure: use exponential backoff with three attempts; if it still fails, write the message to a pending-resend queue.
- Run traceability: log the start time, duration, item count, source success rate, model call volume, prompt version, and final status for every execution, forming a queryable execution history.
- Idempotency control: use “date + watermark” as the business key so manual backfills do not cause duplicate pushes.
6. Common Pitfalls and Optimizations
- Duplicate pushes: usually caused by a missing watermark or idempotency key; adding the business key resolves it.
- Hollow summaries: switch from “summarize” to “extract key points by topic” and require citing item titles; this noticeably increases information density.
- Cost overruns: apply keyword pre-filtering and similarity-based deduplication before the model, and feed only the first several characters of long bodies.
- Prompt drift: model or parameter changes can alter the output style, so keep a regression sample set and run a comparison after each adjustment.
- Missing observability: connect a general logging service and monitoring alerts, with alerts for “two consecutive failed executions” and “source success rate below threshold.”
7. From Scheduled Summaries to a General Agent Workflow
Once this pipeline runs reliably, the same skeleton transfers to many more scenarios: competitor activity tracking, internal document change alerts, build failure attribution summaries, and on-call log clustering reports. The methodology is consistent: scheduled trigger + multi-source collection + normalized cleaning + model generation + multi-channel distribution + end-to-end traceability.
For stronger autonomy, add a “judge and decide” step on top of this foundation — for example, let the model decide the level of detail and whether additional retrieval is needed based on item count and topic distribution. That evolves a fixed pipeline into an agent with limited decision-making ability. When deploying in the cloud, you can use a container platform to host execution nodes, object storage to keep run artifacts, a message queue for peak shaving and resends, and logging plus monitoring alerts for observability. These are all common capability categories in the industry, and you can pick freely according to your own tech stack.
8. Conclusion
The value of automation lies not in technical complexity but in whether it reliably saves people deterministic time. A flow that saves fifteen minutes a day recovers more than sixty hours a year; more importantly, it shifts the team’s attention from “moving information around” to “judging information.” Get the smallest closed loop stable first, then gradually add deduplication, fallback, traceability, and decision-making — that is the most reliable evolution path for this kind of agent workflow.
