From AI Agents to Personal Workflows: A Practical Guide to Building a Stock Analysis System

    This article uses a "daily stock research candidate list" as a case study to show how to move a personal AI agent from a basic deployment to a maintainable application. It covers defining task boundaries, layered architecture design, environment and permission isolation, verifiable custom skills, market data semantics, deterministic screening rules, reliable scheduling and delivery, and security and evaluation practices. The candidate list is for technical validation and research assistance only; it is not investment advice, promises no returns, and involves no automated trading.

    1. Behind the Agent Hype, What Is Really Changing

    Personal agents attract attention not simply because they can hold natural-language conversations, but because they begin to connect “understanding a request” with “executing a task.”

    Traditional conversational applications mainly handle information explanation, text generation, and suggestion output. The user still has to open business systems, query data, run calculations, and organize results. An agent, by contrast, can call external capabilities within an authorized scope and organize multiple operations into a continuous flow, such as fetching market data, checking data quality, computing indicators, generating a research summary, and then sending the result to the user’s message channel.

    This does not mean that deploying an agent instantly yields a reliable personal assistant. Real applications usually still require well-defined data sources, stable tool interfaces, executable rules, task state management, and exception handling. Without these pieces, even if the model can produce fluent explanations, problems such as stale data, misread conditions, or repeated task execution can still occur.

    So the core of building a personal agent is not adding more prompts to the model, but establishing a workflow that can be inspected, constrained, and repeatedly run.

    This article uses a “daily stock research candidate list” as a case study to discuss how to move from a basic deployment to a maintainable application. The candidate list here is for technical validation and research assistance only; it does not represent investment advice, promises no returns, and involves no automated trading.

    2. Define Task Boundaries Before Designing the System

    “Find me five promising stocks every day” looks clear, but it actually contains several undefined conditions: what counts as promising, which market’s data to use, when to run, which indicators to rely on, and what to do when data is insufficient.

    If you hand this sentence directly to the model, the system may adopt a different interpretation each time, making the results hard to evaluate. A more reasonable approach is to convert the request into a task contract.

    1. Define the Inputs

    Inputs should include at least:

    • Research scope: the whole market, a specific industry, or a list of securities provided by the user.
    • Data cutoff time: a specific intraday moment, or the most recent complete trading day.
    • Data granularity: minute-level, daily, or another clearly defined period.
    • Screening rules: liquidity requirements, data completeness requirements, and observation indicators.
    • Output count: at most five candidates, rather than exactly five.
    • Execution mode: manual trigger, scheduled trigger, or event trigger.

    “At most five” is an important constraint. If only two instruments meet the conditions, the system should honestly output two rather than loosening the conditions to fill the count.

    2. Define the Outputs

    Each candidate result should include the security identifier, data time, reason for selection, key indicators, and a risk note. The system should also output the coverage of this screening run, the number of valid samples, and any checks that could not be completed.

    This way, the user sees not just a conclusion but traceable research material.

    3. Define the Prohibitions

    The system should not place orders automatically, should not treat model explanations as market data, and should not fabricate values when data is missing. Any action involving fund operations, permission changes, or external publishing should be isolated from the research and analysis flow and require additional human confirmation.

    3. Architecture Design: Let the Model Understand, Let the Program Handle Facts

    A deployable system can be divided into six layers:

    1. User message entry
    2. ↓
    3. Identity verification and request parsing
    4. ↓
    5. Agent orchestration layer
    6. ↓
    7. Skill execution layer
    8. ↓
    9. Market data and indicator computation layer
    10. ↓
    11. Result storage, task scheduling, and notification

    1. Message Entry

    The message entry receives user instructions, displays results, and collects feedback. It can be a web interface or an instant-messaging entry with bot integration support.

    The message entry should not directly carry data analysis logic. This way, even if the interaction method changes later, the core workflow does not need to be rewritten.

    2. Agent Orchestration Layer

    The orchestration layer is responsible for understanding intent, selecting the skills that are allowed to be called, maintaining task context, and deciding whether to ask the user for more information.

    For example, if the user inputs “analyze the stocks I follow” but does not provide a watchlist, the agent should first retrieve the authorized saved list or ask the user for more information, rather than guessing on its own.

    3. Skill Execution Layer

    A skill is a functional unit with clear inputs, outputs, and permission boundaries, such as:

    • Fetching market data for a specified scope;
    • Validating data completeness;
    • Computing research indicators;
    • Running candidate screening;
    • Generating a result summary;
    • Sending task notifications.

    A skill is not equivalent to a prompt. For tasks involving data retrieval and numerical computation, a skill usually also needs executable logic, parameter checks, error handling, and test cases.

    4. Data and Computation Layer

    This layer should stay as deterministic as possible. The same data and the same rule version should produce the same computation result.

    The model can explain results, but key numbers should be generated by verifiable programs. This division of labor reduces the model’s misreading of numbers and makes it easier to troubleshoot anomalies.

    4. Deploying the Base Environment: Prioritize Control and Observability

    A personal experiment can start on a general-purpose cloud server, but “the process started successfully” should not be equated with “the system can run stably over the long term.”

    1. Isolate the Runtime Environment and Permissions

    The application should use a separate runtime identity and be granted only the necessary network and file access. Market access credentials, message-sending credentials, and administrative credentials should be stored separately, so that if a skill is abused it cannot gain control of the entire system.

    The administrative entry should not be exposed directly to the public network. If remote access is truly needed, use authentication, access restrictions, and encrypted transmission.

    2. Configure Persistent Storage

    At minimum, you need to store task records, rule versions, result snapshots, and error logs. Long-term analysis depends on these records; otherwise users can only see the current day’s results and cannot tell whether the rules are stable or whether the system has changed.

    Logs should not record full access credentials, and should avoid unnecessarily storing sensitive user information.

    3. Design Recovery Mechanisms

    After an application restart, it needs to identify unfinished tasks and decide whether to continue, retry, or mark them as failed based on task state. Scheduled tasks should not rely only on in-process temporary state, otherwise a server restart could cause tasks to be missed.

    For a personal-scale application, prefer a simple, maintainable architecture; only when concurrency, task volume, or reliability requirements increase should you consider introducing message queues and separate execution nodes.

    5. Custom Skills: From “Able to Call” to “Verifiable”

    The focus of a custom skill is to establish a clear contract, not to give the model arbitrary execution power.

    The following is a conceptual skill definition used to illustrate the design idea; it does not correspond to any specific product interface:

    1. Skill name: Generate daily research candidate list
    2. Inputs:
    3. Research scope
    4. Data cutoff time
    5. Rule version
    6. Maximum output count
    7. Preconditions:
    8. User has passed identity verification
    9. Data access permission is valid
    10. Rule version exists
    11. Outputs:
    12. Execution status
    13. Data time
    14. Number of valid samples
    15. Candidate list
    16. Data quality notes
    17. Risk notes
    18. Prohibited actions:
    19. Modifying account permissions
    20. Initiating trades
    21. Using unauthorized data sources

    1. Parameters Must Be Validated

    Do not trust model-generated parameters directly. Research scope, time format, output count, and rule version should all be checked on the program side.

    For example, the maximum output count should be limited to a reasonable range; a nonexistent rule version should be rejected outright; an unsupported data granularity should return a clear error rather than automatically guessing the user’s intent.

    2. Skills Should Keep a Single Responsibility

    Fetching data, computing indicators, and sending messages should not be mixed into one hard-to-inspect function. Once separated, each stage can be tested independently, and it becomes clear whether a failure comes from the data source, the computation logic, or the notification channel.

    3. Require Approval for High-Risk Capabilities

    Reading market data is usually a lower-risk action, but capabilities such as executing arbitrary system commands, installing external code, or deleting files are clearly higher risk. A research-assistance system has no need to open these permissions.

    Even if an external skill’s description looks reasonable, you should first inspect its code, dependencies, network access scope, and data handling before deciding whether to integrate it.

    6. Market Data Integration: Solve Data Semantics Before “Real-Time”

    “Real-time market data” is not a naturally unified concept. Different data sources may have different latency, update frequency, field definitions, and usage restrictions. The system must first make clear what the data means.

    1. Unify the Data Structure

    The internal data model should at least distinguish:

    • Security identifier and its market;
    • Data occurrence time;
    • System retrieval time;
    • Price, volume, and turnover;
    • Data period;
    • Data quality status.

    The data occurrence time indicates which moment a record corresponds to, and the system retrieval time indicates when this record was obtained; the two must not be conflated.

    2. Handle Trading Days and Time Zones

    Running at a fixed time every day does not mean there is new market data every day. The scheduling logic needs to recognize non-trading days, market closures, and trading sessions, and use the most recent valid trading day’s data.

    Cross-market research also needs to handle time-zone differences to avoid directly comparing data that has not yet closed with data that has already closed.

    3. Handle Adjustments and Anomalous Records

    When historical prices are affected by dividends, splits, and other factors, a consistent adjustment basis should be applied and the method used should be recorded. Mixing different bases can distort indicators such as returns and moving averages.

    Suspensions, zero volume, missing fields, or abnormal prices should not simply be filled with default values. The system should flag these cases and either exclude them or lower the result’s confidence according to the rules.

    4. Respect Data Licensing

    Before caching, displaying, or redistributing market data, confirm the scope of use and licensing requirements. Being technically able to obtain data does not mean it can be stored indefinitely or publicly redistributed.

    7. Candidate Screening: Separate Deterministic Rules from Model Explanation

    To illustrate the engineering flow, you can use a set of observational rules: first check data completeness, then exclude samples with insufficient liquidity, and then compute indicators such as price change, volatility, and trading activity.

    These indicators form only research clues and are not enough to prove future returns.

    A conceptual flow is as follows:

    1. data = fetchMarketData(researchScope, cutoffTime)
    2. validData = checkTimeFieldsAndAnomalies(data)
    3. if validData is insufficient:
    4. return "insufficient data" with reasons
    5. indicatorResults = computeIndicators(validData, ruleVersion)
    6. candidateSet = applyScreeningConditions(indicatorResults)
    7. rankedResults = sortByExplicitRules(candidateSet)
    8. finalResults = takeAtMostFive(rankedResults)
    9. explanationText = generateResearchSummary(finalResults)
    10. save data snapshot, rule version, and execution record
    11. return finalResults and explanationText

    The sorting rule here should be explicit and reproducible. If a composite score is used, you need to record indicator direction, normalization method, and weights. You cannot simply let the model judge “which is more promising” based on names or narratives.

    When the model generates the summary, it should use only the provided structured results and should not add unverified company events, financial information, or market rumors. When external facts are involved, an independent data retrieval and verification process is required.

    8. Automated Scheduling and Message Delivery: Avoid Missed Runs, Reruns, and Duplicate Sends

    The difficulty of an automated system often lies not in normal operation but in whether it stays controllable under exceptional conditions.

    1. Use a Unique Task Identifier

    You can form a unique task identifier from the user, trading date, and rule version. When a task is triggered repeatedly, first check whether a result already exists, then decide whether to return the existing record or start a new execution.

    This reduces the risk of duplicate analysis and duplicate notifications caused by network retries.

    2. Distinguish Failure Types

    Network timeouts can be retried a limited number of times; expired permissions require manual handling; incomplete data may require waiting and re-fetching; parameter errors should be reported directly.

    Do not retry all errors indefinitely, otherwise you can easily exhaust resources and mask the real problem.

    3. Store Analysis and Notification State Independently

    If the analysis completes but the message send fails, you should retry the notification rather than re-run the entire analysis flow. Therefore, the task record should store computation state and delivery state separately.

    4. Make Results Suitable for Mobile Reading

    The message body can first show the run time, data cutoff time, and candidate summary, then provide detailed indicators. Exception states should be placed prominently to prevent users from mistaking an old result for the latest one.

    9. Security and Evaluation: Reliability Must Be Provable

    Once an agent encounters external text, it may run into instructions that try to change its behavior. News content, data descriptions, and external documents should all be treated as data to be processed, not as commands with the authority to modify system rules.

    You should establish a skill whitelist, restrict network access scope, require explicit authorization for sensitive operations, and avoid putting keys directly into the model context.

    Evaluation needs to cover both engineering quality and explanation quality:

    • Whether tasks complete as planned;
    • Whether data meets timeliness requirements;
    • Whether the same input yields consistent results;
    • Whether numbers can be rechecked by independent computation;
    • Whether missing data is correctly flagged;
    • Whether the summary accurately cites the computation results;
    • Whether retries cause duplicate notifications;
    • Whether the resource consumption of each run is acceptable.

    If you further study the historical performance of the screening rules, you also need to guard against using future information, ignoring delisted samples, and omitting issues such as transaction costs. Historical results cannot directly imply future performance, and can never be packaged as a return guarantee.

    10. How Agents Change AI Applications and Personal Work Patterns

    From this kind of practice, we can see that AI applications are expanding from “generating content” to “organizing actions.” Data, permissions, state, and evaluation mechanisms beyond the model are gradually becoming an important part of system capability.

    For developers, the competitive focus is no longer just how cleverly the prompts are written, but whether the model can be embedded into a maintainable business process: which steps are allowed to run autonomously, which steps must use deterministic computation, and which steps must be confirmed by a human.

    For individual users, the way of working will also change. In the past, you had to operate pages one by one, copy data, and organize reports; now you can first define the goal and rules, let the system handle the repetitive work, and then have a person check anomalies, judge conclusions, and bear final decision responsibility.

    This is not handing judgment over to machines, but shifting energy from mechanical operations toward task design, result review, and continuous improvement.

    The most worthwhile personal agent is not the one with the most skills or the one that behaves most like a human, but the one with clear task boundaries, trustworthy data sources, traceable results, and explainable failures. Starting with a small-scope research task and gradually filling in data quality, permission control, and evaluation mechanisms is the reliable path from a demo system to an everyday production tool.