Class AgentContext

java.lang.Object
ai.tabforge.workshop.agent.AgentContext

public class AgentContext extends Object

Analogy: Like the work order that the shift leader gives to the worker at the beginning of the shift — it contains exactly what he needs to do (list of files), where is the construction site (projectPath), order number (reviewId), and how much material we can spend (tokenBudget). The worker does not decides what to do — just executes what is written in the work order.

Created by: OrchestratorAgent, after TaskDecomposer finishes his job. TaskDecomposer returns data structure which describes which agent should work with which files, for example:


 │ SecurityAuditorAgent     →  [OrderResource.java, PaymentService.java, ...]
 │ TransactionAnalystAgent  →  [PaymentService.java, AccountEJB.java, ...]
 │ PerformanceAnalystAgent  →  [OrderRepository.java, ...]
 │ ArchitectureCheckerAgent →  [all files, signatures only]
 

Having that, for each agent + his file list, OrchestratorAgent makes AgentContext instance, and starts agent execution by calling SubAgent.execute(), giving it an agent context as parameter.

CERTIFICATION NOTE — Agentic Architecture & Orchestration (27% of exam) - Domain 1. Covers following task statements:

  • Task Statement 1.2: Orchestrate multi-agent systems with coordinator-subagent patterns
  • Task Statement 1.3: Configure subagent invocation, context passing, and spawning

from Claude Certified Architect – Foundations Certification Exam Guide

  • Constructor Details

    • AgentContext

      public AgentContext(String projectPath, List<Path> fileList, String reviewId, int tokenBudget)
  • Method Details

    • getProjectPath

      public String getProjectPath()
    • getFileList

      public List<Path> getFileList()
    • getReviewId

      public String getReviewId()
    • getTokenBudget

      public int getTokenBudget()
      Let's explain in a simple way what a token is in general. A token is a piece of text — roughly a word, or part of a word:
      
       "Hello world"  → 2 tokens
       "OrderResource" → 2-3 tokens
       "@"            → 1 token
       

      It's not exactly one token = one word, but it's a good enough approximation. Let's assume 4 characters make up one token.

      When one of our agents (e.g. SecurityAuditorAgent) sends an API call, that call goes:

      
       [system prompt] ← "You are a security auditor, looking for SQL injection..."
       [file contents] ← the actual Java code it analyzes
       [output schema] ← "respond in this JSON format"
       

      All those words together are INPUT TOKENS. The Claude API response (a JSON with findings) represents OUTPUT TOKENS. Rule: INPUT + OUTPUT must be < 200,000 — that is the context window.

      tokenBudget tells the API how many output tokens its response may use:

      
       tokenBudget = 200,000 - INPUT TOKENS
       

      In practice 8096 tokens is enough for a JSON response, so we take the smaller of the two. ContextWindowManager handles this calculation.

      Returns:
      the maximum number of output tokens allowed for one agent API call