Persistent AI Agents for Unattended R&D Research: A Staged Pipeline with Dual Scheduled Tasks

    Persistent AI agents can run 24/7, call tools, retain state, and trigger work on schedule, but many teams deploy them first and look for use cases later. This article presents a practical method for turning long-running, repetitive R&D research into an observable, checkable, and recoverable pipeline. It starts with capability boundaries and acceptance criteria, then defines deliverables and evidence rules before choosing a deployment form. A staged state machine with versioned state files supports resumable execution. Two scheduled tasks—one advancing research and one auditing quality—separate execution from review and feed issues back into the next cycle. Using source-code memory-mechanism research as an example, the article covers idempotency, retries, human approval gates, least-privilege governance, observability, and a low-risk rollout checklist.

    Many teams encounter a practical problem soon after deploying an always-on automation agent: the system can run, but they do not know what to ask it to do. A common mistake is to start with installation and deployment, then look for scenarios afterward. As a result, teams are influenced by demo-oriented or flashy online examples that do not fit their own business processes.

    A more reasonable order is to first understand the capability boundaries and advantages of persistent agents, then identify tasks that are acceptable, repeatable, and asynchronously executable, and only then decide the deployment form and runtime environment.

    The core advantage of a persistent automation agent is not “generating a piece of code in one conversation.” It is the ability to execute remotely 24/7, call tools, persist state, and trigger tasks on a schedule. It is well suited to turning long-cycle, repetitive, and phased R&D research work into an observable, inspectable, and recoverable automation pipeline. This article uses “source-code memory mechanism research” as an example to abstract a general practice method. It focuses on how to achieve unattended after-hours task progress and how to improve result quality through mutual checking by two scheduled tasks.

    1. Clarify Capability Boundaries Before Matching Business Scenarios

    A persistent automation agent usually has several basic capabilities: understanding natural-language goals, reading code repositories and documents, executing restricted scripts, generating structured reports, saving intermediate state, scheduling tasks periodically, and outputting logs and evidence. Combining these capabilities enables a dual-task mode of “research progression task + quality check task.”

    However, the boundaries must be clearly recognized: complex research is difficult for a model to complete in one pass; model outputs are uncertain; code understanding requires an evidence chain; high-risk write operations must have human approval; and tasks without clear acceptance criteria can easily produce reports that look complete but are actually unusable.

    Therefore, suitable scenarios should prioritize low-risk, acceptable, and asynchronous tasks, such as source module mapping, architecture description generation, configuration inventory, regression checks, monitoring information aggregation, and documentation consistency checks. Unsuitable scenarios include directly operating production environments without isolation, subjective decisions without acceptance criteria, tasks involving sensitive data without a de-identification plan, and high-risk changes that require real-time interactive confirmation.

    2. Replace “Deploy First, Find Scenarios Later” with “Define Deliverables First”

    To make an agent work unattended, the first step is not writing prompts but defining deliverables. For memory mechanism research, the goal can first be broken into an acceptance checklist:

    1. Module map: memory-related modules, entry points, dependencies, and call chains;
    2. Write path: how memory is produced, written, serialized, and persisted;
    3. Retrieval path: recall conditions, ranking logic, filtering rules, and failure fallbacks;
    4. Eviction strategy: capacity limits, expiration mechanisms, and cleanup triggers;
    5. Consistency and concurrency: multi-task writes, conflict handling, and idempotency design;
    6. Configuration and switches: key configuration items, default values, and impact scope;
    7. Risks and open questions: facts, inferences, and uncertainties listed separately;
    8. Evidence index: each conclusion should correspond to a file, function, configuration, or document location where possible.

    Acceptance criteria should also be defined upfront: key conclusions must have evidence; facts and inferences must be distinguished; core questions in the checklist must be covered; uncertainties must be clearly marked; and the report structure must be fixed for rapid manual spot checks. Only when deliverables and acceptance criteria are clear does a scheduled task have a definition of “done,” and only then does a quality check task have a basis for review.

    3. Use a Staged Pipeline Instead of a One-Shot Long Prompt

    For complex research tasks, it is better to split the work into a staged state machine rather than asking the agent to read the entire codebase and output a final report in one pass. A practical pipeline can include: environment preparation, code map, write path analysis, retrieval path analysis, eviction and consistency analysis, summary report, and quality check. Each stage has inputs, outputs, evidence requirements, and completion conditions.

    An illustrative pseudo-code example is as follows:

    1. task_spec = {
    2. "goal": "Analyze the memory mechanism in the source code",
    3. "scope": "Read-only code snapshot and related documents",
    4. "deliverables": ["module map", "write path", "retrieval path", "eviction strategy", "risk list"],
    5. "evidence_rules": "Conclusions must include file and location evidence; inferences must be labeled",
    6. "forbidden_actions": ["modify source code", "access production environment", "export sensitive data"]
    7. }
    8. state = load_state("status.json")
    9. for stage in stages:
    10. if stage.done:
    11. continue
    12. result = agent.execute(stage.prompt, context=readonly_snapshot, state=state)
    13. validate_evidence(result)
    14. save_artifact(result)
    15. update_state(stage, result)
    16. if stage.needs_human_gate:
    17. pause_and_notify()

    State persistence is critical. A versioned state file should record the current stage, completed items, pending items, evidence index, issue list, failure retry count, and human approval status. Each task should append a new version rather than overwrite historical artifacts, making backtracking and diff comparison possible. This allows a failed execution to resume from a checkpoint rather than start over.

    4. Dual Scheduled Tasks: Separate Progression from Quality Inspection

    A valuable practice in the original approach is to create two scheduled tasks: one responsible for advancing research and one responsible for checking and improving it. Separating the two avoids blind spots caused by “writing and judging the same work.”

    The research progression task reads state periodically, executes the next incomplete stage, and generates incremental reports. The quality check task reviews the latest artifacts on a different schedule, checking whether the evidence chain is complete, whether conclusions conflict, whether the checklist has omissions, and whether unauthorized operations occurred. It outputs an issue list and correction suggestions.

    An illustrative scheduling logic is as follows:

    1. schedule:
    2. research_task every 2 hours:
    3. if not complete and no pending_human:
    4. run_next_stage()
    5. append_artifacts()
    6. update_state()
    7. quality_task every 3 hours:
    8. audit_latest_artifacts()
    9. check_evidence_chain()
    10. detect_conflicts_and_gaps()
    11. append_issues()
    12. if critical_issue:
    13. set_gate("pause")
    14. notify_human()
    15. else:
    16. feed_back_to_research_task()

    From an engineering perspective, idempotency and retries need attention: read the latest state before each task starts and write a new version after execution; repeated execution of the same stage must not produce duplicate side effects; failure retries should have an upper limit and trigger alerts; long tasks should have timeouts and time boxes; and external documents should be treated with caution to prevent untrusted content from affecting tool calls. The quality check task should output a structured issue list where possible, such as “missing evidence,” “contradictory conclusion,” “scope violation,” and “unlabeled inference,” rather than vague evaluations.

    5. Case Abstraction: Unattended Completion of Memory Mechanism Research

    To apply the method to an after-hours research task assigned by a manager, the design can work as follows: before leaving work, prepare a read-only code snapshot and an isolated runtime environment, and write the task specification and acceptance checklist; configure a research progression task and a quality check task; set a human approval gate that notifies only for high-risk conclusions or key disagreements.

    Overnight, the progression task first completes a draft module map and write path; the quality task then finds that a conclusion lacks evidence, a module is not covered, or an inference conflicts with the code, and writes an issue list; the progression task supplements evidence, corrects, and expands the work in the next cycle. In the morning, a human only needs to review the summary, evidence index, and open questions, then decide whether to proceed to the next round.

    Similarly, remote coding and rapid prototyping cases show that agents can significantly shorten delivery time, but only when requirements are aligned, boundaries are defined, and acceptance criteria are clear. Unattended does not mean completely unaccountable. Instead, it focuses human effort on goal setting, key decisions, and final acceptance.

    6. Engineering Governance and Cloud Deployment Considerations

    When deploying on cloud, a container platform such as Baidu AI Cloud can host isolated runtime environments, object storage can save source snapshots and intermediate artifacts, and logging and monitoring can provide observability. These are general capability categories, and specific choices should follow organizational standards.

    Governance should follow least privilege: read-only source code, tool call allowlists, restricted network access, managed secrets, and production write operations prohibited or requiring approval. For observability, record each step’s input/output summary, duration, failure reason, and cost anomalies. For quality, establish an evidence chain, sampled human review, version diff comparison, and a regression check set. For security, perform sensitive information de-identification, prompt injection protection, and output review.

    7. Implementation Checklist

    It is advisable to start with a low-risk, acceptable small task: write clear deliverables and evidence rules; prepare an isolated read-only environment; split stages and maintain a state file; set up “progression + quality check” dual periodic tasks; configure a human approval gate; connect logging, monitoring, and alerting; and turn lessons learned into a reusable template after review.

    The real value of persistent agents is not to show off, but to convert repetitive research into a runnable, checkable, and recoverable automation pipeline. Clarify the scenario first, then deploy the system, so that “completing tasks after hours” can move from an occasional case to a stable capability.