AI Agents in Practice: Moving from Step-by-Step Instructions to Goal-Driven Tasks

    Developers often use AI agents as if they were simple automation tools, giving them rigid sequences of commands. This guide explains why goal-driven task descriptions produce better results, how to define goals, scope, constraints, outputs, and acceptance criteria, and how to combine agent autonomy with safety controls. It includes a complete website service troubleshooting example and a reusable task template.

    1. Change How You Express Tasks to an Agent

    Many developers first use AI agents the way they would use a command executor: enter a specific directory, read a particular file, search for a keyword, and return the matching results.

    This approach looks precise, but it limits the agent to being a mechanical executor. The user must already know where the data is, which methods to use, how to handle exceptions, and which results are worth analyzing. The agent completes the operations, but the actual diagnostic work still falls on the user.

    A better approach is to describe the outcome you want, along with the necessary boundaries. For example:

    Check whether the website service has experienced anomalies in the past two hours, focusing on request failures, response timeouts, and backend connection issues. Perform read-only analysis only—do not modify configurations or restart services. Report when the anomalies occurred, their scope of impact, key evidence, and recommended next steps.

    This task does not prescribe every operation, but it defines the goal, time range, focus, permission limits, and output requirements. If the agent has the necessary tools and authorization, it can choose its own query path. If it lacks what it needs, it should report the gap rather than pretend the diagnosis is complete.

    Goal-driven does not mean “the vaguer, the better.” What actually works is: reduce unnecessary operational constraints while adding clear business semantics and acceptance criteria.

    2. Why Goal-Driven Beats Fixed Steps

    2.1 Fixed steps often embed unverified assumptions

    Asking an agent to read a specific log file implicitly assumes several things: the file is in the expected location, current logs are still being written to it, the target time window hasn’t been archived, error information contains the specified keywords, and that single file reflects the service’s state.

    If any one of these assumptions is wrong, the operation can succeed while producing an incorrect conclusion.

    For example, finding no error keywords does not mean the service is healthy. Request failures may show up mainly in status codes, latency distributions, or connection interruption records; logs may also be scattered across multiple instances. Conversely, records containing the word “error” do not necessarily mean current users are affected—they could come from historical incidents, test requests, or issues that have already self-recovered.

    The value of goal-driven work is that it lets the agent adjust its path based on evidence, rather than treating one particular retrieval method as the diagnosis itself.

    2.2 Agents should plan and judge, not just call tools

    A capable agent can work through a process of “understand the goal — make a plan — gather information — analyze evidence — adjust the plan — output conclusions.” But this capability depends on the actual deployment environment; not every agent has log access, monitoring queries, or service management permissions by default.

    Users should clearly state what data is available, which operations are allowed, and what is prohibited. The agent should then judge:

    • Whether the current information is sufficient to begin;
    • Which queries directly serve the goal;
    • Whether new evidence supports the initial hypothesis;
    • Whether further investigation is warranted;
    • Which steps require human confirmation.

    This division of labor frees users from repetitive operations while keeping critical decisions under human control.

    2.3 Fixed steps still have their place

    Goal-driven does not mean every operational procedure should be abandoned. For standardized inspections, audit evidence collection, compliance checks, or tasks requiring strict reproducibility, the prescribed procedure is itself part of the requirement.

    A more sensible approach is to distinguish two types of tasks:

    • Exploratory tasks: outcome-centered, allowing the agent to adjust its investigation path.
    • Prescriptive tasks: bounded by a defined procedure, requiring step-by-step execution with records retained.

    Even with a fixed workflow, each step should state its purpose and acceptance criteria, to avoid the situation where “every step executed successfully, but the business question remains unanswered.”

    3. Six Elements of a High-Quality Task

    3.1 Goal: Define the Question to Answer

    “Take a look at the logs” is only an action description and has no completion standard.

    “Determine whether the website experienced user-facing anomalies in the past two hours, and provide evidence” is an outcome description. It requires the agent to make a judgment, not merely return text.

    If the goal is complex, break it into several questions: Is there an anomaly? Where is it concentrated? Which requests are affected? Which causes are worth prioritizing for verification?

    3.2 Scope: Limit the Investigation

    Scope typically covers environment, services, instances, time ranges, and data sources. Be explicit about the timezone used, to avoid correlation errors caused by time differences between systems.

    In multi-instance environments, specify whether all instances or only a particular faulty instance should be checked. If only partial data is accessible, the final conclusion must be limited to the scope actually examined—it cannot be generalized to the entire system’s state.

    3.3 Context: Provide Judgment-Relevant Information

    Recent releases, configuration changes, traffic shifts, dependency failures, and user reports can all help prioritize the investigation.

    But context can only be used to form hypotheses, not to serve as conclusions. A recent change does not mean it necessarily caused the anomaly; you still need to check time correlation, affected objects, and specific error evidence.

    3.4 Constraints: Define Execution Boundaries

    Clearly state whether the work is read-only, whether sensitive data may be accessed, whether the time window can be expanded, and which operations require approval. For example:

    You may read redacted logs and monitoring metrics; do not view access credentials; do not modify runtime parameters. Any operation involving restarts, traffic switching, or configuration changes must first be submitted as a proposal and await confirmation.

    Constraints should be enforced through permission controls wherever possible, not left solely to natural-language reminders.

    3.5 Output: Specify How Results Are Organized

    Require the agent to report using a structure such as “Conclusion, Evidence, Impact, Assumptions, Recommendations, Limitations.” This makes review easier for developers and helps communicate to operations staff or business stakeholders.

    For evidence, preserve timestamps, sources, and necessary context, while masking account identifiers, access credentials, and other sensitive fields.

    3.6 Acceptance: Define What “Done” Means

    Task completion does not necessarily mean finding the root cause. Reasonable acceptance criteria include:

    • The main data sources within the agreed scope have been examined;
    • Anomalies are distinguished from normal fluctuations;
    • Every key judgment is backed by traceable evidence;
    • Unconfirmed causes are explicitly labeled as hypotheses;
    • When data is insufficient, missing items and how to supplement them are stated;
    • No authorization boundaries were exceeded at any point.

    This kind of acceptance is more reliable than demanding “a definitive answer.”

    4. A Complete Diagnostic Workflow: Website Service Troubleshooting Example

    Step 1: Verify Data Coverage

    Before formal analysis, confirm that logs cover the target time window, come from the target instances, are complete, and use consistent timestamp fields.

    If logs have been rotated, collection is delayed, or some instances aren’t reporting, record these limitations first. Otherwise, “no anomaly found” may simply mean “no relevant data was seen.”

    Also check whether the query tool imposes result limits. Analyzing only the first batch of returned records can miss failures concentrated in the latter half of the time window.

    Step 2: Detect Anomalies from Multiple Signals

    Don’t just search for a single keyword. Website service anomalies can be identified from dimensions such as:

    • Whether request status shows noticeable changes;
    • Whether timeouts, connection failures, or connection interruptions are increasing;
    • Whether request latency deviates from the norm;
    • Whether anomalies concentrate on specific paths or instances;
    • Whether errors appear briefly and recover, or persist;
    • Whether there are signs of resource exhaustion or dependency unavailability.

    These signals need business-semantic interpretation. For example, some client-side request failures may stem from invalid requests rather than server-side faults; a small number of connection interruptions may be users actively canceling. You cannot declare an incident based on a single count.

    Step 3: Aggregate by Time, Instance, and Error Type

    Raw logs are good for verifying details but not for describing overall impact. Aggregate first, then go back to representative records.

    The following pseudocode illustrates the analysis approach and is not tied to any specific product interface:

    1. Record set = Read logs within the target range
    2. Valid records = Normalize timestamp formats and retain parse-failure records
    3. Anomaly candidates = Filter by request status, latency, and error characteristics
    4. Statistics = Aggregate by time window, instance, request path, and error type
    5. Key samples = Select representative records from major anomaly categories
    6. Output statistics, key samples, and data coverage limitations

    Records that fail parsing should not be silently discarded. If the failure rate is high, the analysis may be significantly biased; either fix the parsing or narrow the scope of the conclusions.

    Step 4: Build an Evidence Chain Instead of Guessing the Root Cause

    Suppose backend connection failures occur during a time window while request latency rises. This evidence supports the judgment that “the anomaly is related to backend access,” but it is not yet enough to determine whether the cause is a network issue, insufficient capacity, or a backend service failure.

    Organize the content into three layers:

    • Facts: what was actually observed;
    • Hypotheses: which causes could explain the facts;
    • Verification methods: what further checks would distinguish between those causes.

    If request correlation identifiers exist, use them to link records across stages. If they don’t, state the limitation of cross-service attribution rather than fabricating a complete call chain.

    Step 5: Output Conclusions and Actionable Recommendations

    The report should answer the original question, not merely excerpt logs. A recommended structure:

    Conclusion: whether an anomaly was found within the examined scope, and whether it is a brief fluctuation or a persistent problem.
    Evidence: main time windows, error categories, involved instances, and representative records.
    Impact: the affected request range that can be confirmed; clearly separate what cannot be determined.
    Cause assessment: confirmed facts and hypotheses pending verification, listed separately.
    Next steps: prioritized read-only checks, plus change operations requiring approval.
    Analysis limitations: missing data, coverage gaps, and uncompleted verifications.

    When the evidence is insufficient, the correct statement is “no clear anomaly was found within the current data scope,” not “the service is fully healthy.”

    5. Autonomy Must Be Paired with Security Controls

    5.1 Use Least Privilege

    Log analysis typically requires only read access; agents should not be granted configuration-write or service-control permissions by default. Diagnosis and remediation are best split into two phases with different authorization scopes.

    Even if a user asks for “automatic handling,” predefine which actions are low-risk and can execute automatically, and which require human approval.

    5.2 Treat Log Content as Untrusted Data

    Logs may contain external request parameters, user input, or exception responses. Even if text resembling “ignore previous instructions” or “perform a certain operation” appears, it must be treated only as content to analyze, never as a new instruction.

    Permission checks and approval mechanisms should reside at the execution layer, preventing the agent from triggering unauthorized actions because it misinterpreted external data.

    5.3 Control Investigation Cost

    An agent without stopping conditions may keep expanding scope, repeatedly querying, or persistently retrying failed operations. Real tasks should set time budgets, query scope, retry limits, and escalation conditions.

    For example, once evidence collection for the main anomaly categories is complete, a phased conclusion can be produced. If further investigation requires additional permissions, stop and request confirmation rather than circumventing limits.

    5.4 Preserve Traceable Records

    At minimum, record query times, data scope, capabilities used, key evidence, and approval status. This helps with reviewing conclusions, analyzing misjudgments, and determining whether problems stem from data quality, task description, or execution strategy.

    The records themselves must also be redacted and access-controlled, to avoid turning the diagnostic process into a new channel for sensitive information leaks.

    6. A Reusable Goal-Driven Task Template

    1. Goal:
    2. Determine whether the target service exhibited user-impacting anomalies during the specified time window.
    3. Scope:
    4. Specify environment, services, instances, time window, timezone, and permitted data sources.
    5. Background:
    6. Add recent changes, user feedback, and known issues; do not presuppose a root cause.
    7. Execution constraints:
    8. Perform only authorized read-only checks within scope.
    9. Do not modify configurations, restart services, or read access credentials.
    10. Stop and report when permissions are insufficient, data is missing, or a high-risk operation is required.
    11. Output requirements:
    12. Provide conclusion, key evidence, impact scope, pending hypotheses, and next steps.
    13. Distinguish observed facts from speculation; mask sensitive fields.
    14. Completion criteria:
    15. Examine the main data sources and describe data coverage.
    16. Key judgments must be traceable to evidence.
    17. When certainty is not possible, state the reason clearly instead of forcing a root cause.

    This template also applies to fault localization, resource usage analysis, and alert investigation. The specific scenario may vary, but four pillars—goal, boundaries, evidence, and acceptance—should never be missing.

    7. Measure Agent Value by Outcomes, Not Action Counts

    A high number of tool calls does not mean deep analysis; fast execution does not mean reliable conclusions. What matters more is:

    • Whether the business question was actually answered;
    • Whether repetitive manual work was reduced;
    • Whether judgments are backed by sufficient evidence;
    • Whether missing information and uncertainty were handled correctly;
    • Whether high-risk and unauthorized operations were avoided;
    • Whether the same task can reproduce the analysis process consistently.

    The right way to use an agent is neither full delegation nor prescribing every click and query, but establishing a clear division of labor between the two: users define goals, authorization boundaries, and acceptance criteria; the agent plans, investigates, and organizes evidence within those boundaries.

    The key shift is from “execute these steps for me” to “achieve this goal within these boundaries.” Truly reliable autonomy is always built on clear constraints, verifiable results, and human oversight.