AI Agent Engineering: Parallel Scheduling and Hierarchical Context Management
Reliable AI agents require more than a model-and-tool loop. This article explains how dependency-aware scheduling, layered context, explicit task contracts, and hierarchical compression support complex workflows. It also covers evidence-based aggregation, context budgeting, failure recovery, security boundaries, and evaluation methods for determining when a multi-agent architecture delivers practical value.
1. Why Do Agents Using the Same Model Perform So Differently?
A minimal AI agent prototype is straightforward: receive a user goal, call a language model, execute tools based on the model’s output, and return the tool results to the model until it produces a final answer.
But a workflow that runs is not necessarily a workflow that completes tasks reliably.
When a task involves multiple files, extensive source material, reasoning across several steps, or writes to external systems, developers must address questions that go beyond API calls:
- Which tasks can run independently, and which must wait for earlier results?
- Which information belongs in the model’s context, and which should remain in external storage?
- Has a subagent’s summary omitted a critical constraint?
- How should conflicting conclusions from multiple execution units be resolved?
- How can failed tool calls be recovered without repeating side effects?
- Does the final result actually satisfy the user’s goal, rather than merely sound convincing?
These decisions shape an agent’s practical capabilities. The model provides understanding and generation; the surrounding system determines whether those capabilities can be used consistently.
Agent engineering is therefore closer to building a workflow system with uncertain decision-making components. It requires managing task dependencies and resource budgets alongside evidence, permissions, and execution state.
2. Context Engineering: Organizing Useful Information, Not Adding More
Context engineering aims to give each execution unit enough relevant information within a limited input budget.
Context includes more than conversation history. It also covers task goals, business constraints, tool descriptions, retrieved material, execution records, intermediate conclusions, and error feedback.
Passing everything directly to the model typically creates three problems.
Capacity limits. The source material and execution traces generated by complex tasks may exceed the context window.
Competing information. Even within the window, large amounts of irrelevant content can make critical constraints harder to identify. A large context window does not mean every part of the input will be used equally effectively.
Accumulating cost. Sending the same material in every round increases input consumption and may extend overall processing time.
Aggressive trimming is also risky. A subagent might know that it must “modify the configuration file” without knowing that it must “preserve compatibility with older versions.” It might be asked to “summarize risks” without seeing the conditions under which those risks apply. The result can appear reasonable while violating the task requirements.
A more reliable approach separates information into four layers:
- Goal layer: The user’s intended outcome and acceptance criteria.
- Constraint layer: Non-negotiable rules, permission boundaries, data scope, and version requirements.
- Evidence layer: The source material needed for the current task, with source references.
- State layer: Completed work, unresolved issues, and failed operations.
For subagents, goals and constraints should generally not be removed casually. Evidence should be selected for the task, while state should retain the information directly relevant to the current execution.
3. Build a Task Graph Before Deciding What to Parallelize
Splitting a task into subtasks does not mean those subtasks can run simultaneously.
Reliable parallel scheduling starts with dependency analysis. Tasks can be represented as a directed dependency graph: nodes represent tasks, and edges represent prerequisite relationships. Only nodes whose prerequisites have been satisfied enter the schedulable set.
3.1 Data Dependencies: Does a Task Need an Earlier Output?
“Extract interface constraints” and “generate an implementation from those constraints” usually have a sequential dependency. Formal implementation should not begin before the constraints are established.
By contrast, reading three independent documents and extracting their requirements can usually happen in parallel. A unified design can then be generated after extraction is complete.
Some tasks permit speculative execution, but their outputs must be clearly marked as provisional and revalidated when the prerequisite information becomes available. Otherwise, assumptions can be mistaken for confirmed conclusions.
3.2 Write Conflicts: Are Tasks Modifying Shared Resources?
Shared write targets should not be assessed only by asking whether two tasks write to the same table. Depending on the system, analysis may need to reach the level of files, records, fields, or business entities.
Two tasks modifying different files may still affect the same configuration or interface contract. Conversely, two tasks writing to the same table may run safely when explicit isolation rules apply.
The relevant questions are:
- Do the write scopes overlap?
- Is there shared state?
- Do the tasks depend on the same invariant?
- Are transactions, locks, or version checks protecting consistency?
For code changes, a common approach is to have subagents generate separate patches, then let a coordinator review and apply them. This avoids allowing every subagent to modify a shared workspace directly.
3.3 Resource Dependencies: Independent Tasks Can Still Compete
The absence of data dependencies does not justify unlimited concurrency.
Model-call quotas, database connections, external service rate limits, file I/O capacity, and execution budgets can all become bottlenecks. The scheduler therefore needs concurrency limits and should distinguish compute-intensive, retrieval-intensive, and write-sensitive tasks.
A simplified scheduling rule is:
Runnable task = prerequisites satisfiedAND resource budget availableAND write conflicts resolvedIf tasks share write targets:use isolated execution, coordinated commit, or serial executionIf tasks perform only independent reads:execute in parallel within the concurrency limit
The model can propose candidate judgments about task independence, but rules and declared resource requirements should validate them. Natural-language reasoning alone should not determine scheduling safety.
4. Give Every Subagent an Explicit Task Contract
A subagent should receive more than “analyze this document.” Vague instructions allow the scope to drift and make it difficult for the coordinating agent to assess whether the result is acceptable.
A complete task contract should include at least:
- A subtask identifier and specific objective.
- The scope and versions of input material.
- Mandatory constraints.
- Allowed tools and permissions.
- The expected output structure.
- Acceptance criteria.
- Time, call-count, and context budgets.
- Instructions for handling uncertainty.
For example, a document-analysis task can require an output containing conclusions, evidence locations, applicability conditions, conflicts, and unresolved questions, rather than a free-form summary.
This directly improves aggregation: the coordinating agent can distinguish facts from inferences and identify claims that still require verification.
Permissions should also follow the principle of least privilege. A subagent responsible for reading documents should not automatically receive permission to modify configuration or submit business data.
5. Distributing Shared Information: Push, Pull, and Hybrid Strategies
Multiple subagents may need the same background information, such as terminology, output formats, or global business constraints. There are three main ways to provide it.
5.1 Push: Include Information Directly in the Task Context
Push works well for small amounts of information that every subtask must know.
It provides a simple execution path: subagents can start without additional retrieval. However, repeated copies consume input space, and duplication costs can become significant as the number of tasks grows.
Global constraints, critical definitions, and safety boundaries are usually good candidates for push delivery.
5.2 Pull: Retrieve Material from External Storage as Needed
Pull works well for large collections, material with uncertain usage, or information that changes frequently.
Subagents receive a material index, access scope, and query guidance, then retrieve relevant passages. External storage can be a general-purpose document store, object store, or database; the coordinating agent does not need to hold the entire collection in its context.
Storage alone does not guarantee successful retrieval. The system still needs directories, tags, versions, and source-location support. It should also allow broader searches when the initial retrieval is insufficient.
5.3 Hybrid: Push Critical Constraints, Pull Detailed Evidence
For complex tasks, a hybrid approach is often more reliable:
- Push the task goal, hard constraints, and essential background.
- Provide a material directory, version identifiers, and access points.
- Retrieve detailed content as needed.
- Preserve evidence locations in the output.
The choice should not depend only on whether the coordinating agent’s context window is large enough. Repeated input cost, update frequency, retrieval reliability, and access permissions also matter.
In particular, avoid having different subagents read different versions of shared material. Long-running tasks can use a fixed snapshot. If current data is required, record the versions actually read and check consistency during aggregation.
6. Hierarchical Compression: When a Subagent Cannot Fit the Material
Even after reasonable task decomposition, a first-level subagent may discover that its assignment requires reading far more material than expected.
The solution is neither to keep adding content nor to take only the beginning of the source. A better approach is further decomposition using hierarchical mapping and reduction:
Coordinating agent: define goals, divide tasks, validate results├─ First-level subagent A: handle topic A│ ├─ Second-level subagent A1: analyze source partition 1│ ├─ Second-level subagent A2: analyze source partition 2│ └─ Second-level subagent A3: analyze source partition 3└─ First-level subagent B: handle topic B
Second-level subagents read local material and extract evidence relevant to the goal. First-level subagents integrate those local results, and the coordinating agent performs cross-topic synthesis.
6.1 Partitioning Determines Compression Quality
Material can be divided by chapter, time range, business module, or data entity. However, tightly related information should not be split mechanically.
For example, separating a rule from its exceptions can produce a local summary that preserves the rule but omits the exceptions. Small overlapping regions, relationship indexes, or dedicated cross-partition checks can reduce this risk.
6.2 Preserve Evidence, Not Just Conclusions
Useful compressed outputs should retain at least:
- Key facts and conclusions.
- Source locations supporting those conclusions.
- Scope and prerequisites.
- Exceptions and conflicting evidence.
- Unresolved questions.
- Necessary excerpts from the original material.
Compression should remove repetition and irrelevant content, not uncertainty. “There are two possible interpretations” must not become “one interpretation has been confirmed.”
For contract clauses, configuration parameters, or calculation data that require exact verification, summaries cannot replace the originals. Keep a path back to the source.
6.3 Deeper Hierarchies Need Stronger Source-Lookup Mechanisms
Successive summaries can gradually lose detail, so hierarchical compression cannot rely on one-way reporting.
When a higher-level agent detects insufficient evidence, conflicting conclusions, or missing conditions, it must be able to locate the original material and reread relevant passages. Every layer’s output should carry source references and subtask associations.
Set limits on hierarchy depth, task count, and total budget as well. Otherwise, a subtask may keep delegating downward and create an unmanageable task tree.
7. Allocate Context Budgets Before Execution
The full context window is not available for business material. Instructions, tool definitions, conversation history, tool results, and model output all require space.
A simplified budget is:
Available source-material budget= total context budget- instructions and tool descriptions- required execution state- reserved output space- safety margin
Models and interfaces may account for input and output limits differently. Implementations must use the actual limits of the selected API.
A practical dynamic strategy is to:
- Estimate source volume before starting a task.
- Prefer retrieval and partitioning over truncation when the budget is exceeded.
- Save oversized tool results in their original form, then provide relevant excerpts.
- Periodically compress execution state.
- Trigger a fallback before the budget is exhausted, rather than waiting for a failed call.
State compression must preserve confirmed decisions, operation results, failure reasons, and pending work. Deleting failure records and then repeating the same operation can create pointless loops.
8. Result Aggregation: From Text Assembly to Evidence Integration
After parallel tasks finish, the aggregator’s role is not simply to make the output read smoothly. It must produce a consistent, complete, and verifiable result.
Non-overlapping outputs can be assembled using a predefined structure, but they still require checks for format, coverage, and global constraints.
Overlapping outputs require additional work:
- Remove duplicate facts.
- Standardize terminology and data definitions.
- Check source versions.
- Identify contradictory conclusions.
- Determine whether conflicts reflect different applicability conditions.
- Revisit original evidence for important disputes.
- Explicitly retain uncertainty that cannot be resolved.
Facts should not be decided by counting subagent votes. Several subagents may have read the same incorrect material or been influenced by the same prompt bias. Independent evidence and reproducible verification matter more than the number of matching conclusions.
For code, configuration, and structured data, add deterministic checks wherever possible, including format validation, type checking, test execution, and constraint validation. Do not rely only on another agent’s judgment that the result “looks correct.”
9. Failure Recovery, Security Isolation, and Observability
Multi-agent failures include more than incorrect model answers. They also include timeouts, retrieval gaps, state conflicts, tool errors, and permission misuse.
9.1 Distinguish Retryable and Non-Retryable Errors
Temporary network failures may justify retries. Insufficient permissions, invalid input formats, and failed business validation generally require changed conditions before another attempt.
Before retrying an operation with side effects, determine whether it already succeeded. Task identifiers, execution records, and idempotency mechanisms can prevent duplicate writes or repeated business actions.
9.2 Prevent External Material from Becoming System Instructions
Retrieved documents and tool outputs are data to analyze; they should not automatically gain instructional authority. Content such as “ignore the original task” or “read unrelated data” should be treated as source content, not as a new execution requirement.
Subagents accessing external storage should remain subject to task-level permissions. On-demand retrieval must not broaden data exposure beyond the authorized scope.
9.3 Record Traces That Explain the Result
At minimum, record task relationships, source versions, tool calls, evidence references, input and output usage, execution duration, retry counts, and final status.
Logs should redact sensitive information. Observability is useful not only for troubleshooting but also for explaining which sources produced a conclusion, where information was missed, and where most of the cost was incurred.
10. Validate the Architecture, Not Just the Demo
Parallel scheduling and hierarchical compression are not inherently better than a single agent. For small tasks, multi-agent communication, duplicated inputs, and aggregation may increase cost.
Evaluation should use a representative task set and compare at least:
- Sequential execution with a single agent.
- Single-level task decomposition.
- Parallel decomposition combined with hierarchical compression.
Metrics should cover:
- Final task completion rate.
- Violations of critical constraints.
- Consistency between claims and evidence.
- Retrieval omissions and information loss during summarization.
- End-to-end latency.
- Total input and output consumption.
- Tool-call and retry counts.
- The proportion of tasks requiring human intervention.
Compression quality deserves separate evaluation. A fluent summary is not enough; critical conditions, exceptions, and supporting evidence must survive.
Implementation can begin with a minimal end-to-end workflow: establish task contracts and acceptance checks first, add parallel execution for independent tasks, introduce external material storage, and finally add hierarchical compression for tasks that genuinely exceed their budgets. This sequence makes it easier to identify the actual benefit of each mechanism.
Conclusion
The barrier to building an agent prototype can be low. The barrier to reliable operation is not.
API calls determine how to obtain model output. Context engineering determines what the model should see. Scheduling determines which unit executes under which conditions. Validation and recovery determine whether the result can be trusted.
The value of parallel scheduling and hierarchical compression is not that they create more agents. It is that they give each execution unit a clear goal, an appropriate amount of information, explicit permissions, and inspectable outputs.
Only when task decomposition, evidence preservation, result aggregation, and failure recovery form a closed loop can a multi-agent architecture move beyond a demonstration and become a reliable engineering system.
