How to Use AI Agents: Goal-Driven Work and Practical Engineering

    A practical guide to treating coding and operations agents as schedulable executors rather than chatbots: switch from Q&A to delivery, set goals and acceptance criteria, limit tool permissions, manage context and reusable skills, choose models by task, and gate scheduled automation.

    Many teams treat a terminal agent as a chatbot that can type commands: a vague question returns a suggestion, and people still change configs, read logs, and tidy repositories themselves. Teams that use agents well do the opposite. They treat the agent as a schedulable executor: they set the goal, boundaries, and definition of done; the agent uses tools to gather facts; people decide what to keep. The difference is not polished wording. It is whether the interaction model has moved from “question and answer” to “delivery.”

    1. Separate the two interaction modes

    Question-and-answer mode means you ask and the model organizes language. It fits explaining concepts, comparing options, and drafting descriptions. Execution mode means you declare the state you want reached. Within its authorization, the agent reads files, runs commands, changes artifacts, and returns evidence.

    Take “Is the server healthy?” In Q&A mode you often get a checklist. In execution mode the agent should, on hosts it is allowed to touch, inspect load, memory, disk, and key processes, then judge from real output—not invent numbers from general knowledge. If the environment does not allow remote execution, it should say so clearly and list what you need to provide, instead of pretending it has seen the live system.

    The first principle follows: if a tool can verify it, do not rely on opinion alone. An agent’s value is shortening the loop of hypothesis, evidence, and correction—not replacing your judgment.

    2. Give goals, not micromanagement

    Micromanaged instructions look professional but often lock in a bad path. If you dictate “enter this directory, filter with this word, then paste the full text,” the model follows mechanically and can miss a better rotated log, time range, or severity level. State the outcome and add constraints:

    • Goal: decide whether the web service has shown persistent errors over a recent window.
    • Scope: read-only on the specified host and log directory; do not change config or restart processes.
    • Acceptance: report the time window, error types, rough frequency, whether availability is affected, and a short summary of the command output you relied on.
    • When unsure: stop and ask. Do not guess paths or accounts.

    Compare these two prompts:

    1. Weak: Enter the log directory, filter for error, and paste the full text.
    2. Better: Read-only check whether service errors have persisted over the last hour.
    3. Summarize types, counts, and whether immediate action is needed.
    4. Do not modify any files.

    Goals must be checkable. “Optimize it” or “use your judgment” cannot be accepted. “Explain current startup time and name the three heaviest initialization steps” can. You may hint at preferred steps, but write them as constraints, not a script—for example, “prefer scripts already in the repo; do not add new dependencies.”

    3. Permissions, tools, and how to fail

    Agents are strong because of tools, and the risk is also in the tools. Before rollout, draw three layers:

    1. Read-only: list directories, read docs, check status, run diagnostics that do not change the system. Good for discovery.
    2. Workspace-writable: only the current project or a temp directory. Changes must be diffable and reversible. Good for code edits and reports.
    3. High impact: delete data, change permissions, publish externally, or touch production config. Off by default; approve each time explicitly.

    Keep grants small. One session should open only the directories and command classes needed for that goal. Do not put keys, tokens, or production database connection strings into context that can be echoed in full. When they are required, inject them through the environment, and forbid writing secrets into commits or chat excerpts.

    Also define how to stop on failure. Non-zero exits, missing paths, and insufficient permissions should halt and be reported—not trigger a more dangerous command “just to try.” Do not run network install scripts or one-liners from unknown sources without review. Turn installs, upgrades, and batch jobs into steps you can read, or confine them to an isolated environment.

    A task brief can look like this:

    1. Goal: Read-only analysis of why the build failed in the current repository.
    2. Allowed: Read source and build logs; run existing test or build commands.
    3. Forbidden: Modify files, install new packages, or access paths outside the repo.
    4. Output: Failure stage, key error text (excerpt), the most likely single-layer cause,
    5. and a suggested next step (do not execute it).

    4. Context, memory, and reusable skills

    Long sessions fill up with irrelevant output, and the model starts repeating ideas you already rejected. A practical fix is to reset context by stage: when exploration ends, write a short conclusion (symptoms, evidence, ruled-out items, open questions). The next stage carries only that note and the necessary files—not the full terminal scrollback.

    Split memory into three kinds so you do not “remember everything”:

    • Project facts: directory conventions, build entry points, environment differences. Put them in repo docs, not only in one chat.
    • Preferences: commit-message language, whether auto-format is allowed. Store them in versioned instructions so people can review them.
    • One-off context: this incident’s timestamp, a temporary branch. Discard it when the task ends; do not write it into long-term memory.

    A “skill” is really a reusable operation card: trigger, inputs, key steps, prohibitions, and an output template. A “pre-release check” card might cover tests, version number, changelog, and rollback notes—not production passwords. Keep cards short. A long card freezes a bad process. People still own updates. The agent may draft a card; it must not turn an unverified shortcut into the standard action on its own.

    5. Choose models by the task, not by slogans

    No single model is best at every job. Split by task:

    • Broad reading and summarization: long context and stable instruction following matter more.
    • Precise edits and patches: sensitivity to local code and format constraints; prefer smaller steps and multiple checks.
    • Cheap exploration: use a lower-cost model to list hypotheses and files, then switch to a more reliable model for changes.

    Free or low-cost quotas are fine for trying a workflow. They should not be the only basis for a production change. At every tier, use the same acceptance checks: did tests actually run, does the diff exceed the goal, and were unrequested refactors introduced? Do not replace failing cases with “it feels smarter.”

    Control how you call the model. Stuffing the whole repo into context repeatedly is expensive and easy to derail. Have it locate relevant files first, then read those closely. Ask for structured output: conclusion, evidence, change list, and risks—so you can scan instead of reading prose end to end.

    6. Scheduled automation needs gates

    Scheduled jobs fit work that is stable, repeatable, and cheap to fail: a daily dependency-vulnerability summary, dead-link checks in docs, or health snapshots of non-production environments. They do not fit unattended production edits, releases, or data cleanup.

    For each scheduled item, write at least: where the data comes from, what success looks like, who is notified on failure, how many retries are allowed, and whether writes are allowed. Consecutive failures should trip a circuit breaker, not retry forever and flood alerts. Put outputs somewhere traceable—for example a report object in object storage, or a structured record in a logging service—and alert on failure rate and duration. On a cloud platform such as Baidu AI Cloud, ordinary logging, monitoring alerts, and object storage are enough to hold records and archives. Do not place the agent directly on a high-privilege production network.

    7. How this fits cloud troubleshooting

    Agents are good at evidence and drafts. Cloud components are good at audit trails and notification. A workable loop is:

    1. A person defines the symptom and time window.
    2. The agent, read-only, collects metrics, log snippets, and recent changes.
    3. The conclusion is a short report: symptom, evidence, ruled-out items, suggested actions.
    4. The report and raw excerpts go to logs or object storage; alerts fire only when a threshold is crossed.
    5. Changes still go through your existing review and release process.

    Do not make the agent the only on-call channel. It will miss context, and it will turn a one-off error into a trend. People should spot-check that evidence cites real output from this run, not fluent speculation.

    8. Common failures and a short self-check

    Failures usually come from five patterns: treating advice as an executed result; opening write access while the goal is vague; searching freely in directories that contain secrets; stuffing unrelated tasks into one conversation; and scheduled jobs with no circuit breaker. A short self-check covers them:

    • Do you want an explanation, or a result someone can verify?
    • Is write access limited to the workspace, and do high-impact actions still need a person?
    • Could a third person understand and recheck the acceptance criteria?
    • Does the evidence come from this run’s commands or files, not an old conclusion in memory?
    • On failure, will it stop—rather than escalate privileges and push through?

    Used this way, an agent does not magically take responsibility for you. It does compress repeated evidence gathering, draft edits, and formatting into minutes, so your time stays on architecture choices, risk, and the final sign-off. Start with one small read-only goal, get “goal → evidence → acceptance” working, then add memory cards and schedules. That is much steadier than turning on full automation in production on day one.