CCAR-F practice question 3 of 10

You are building developer productivity tools using the Claude Agent SDK. The agent helps engineers explore unfamiliar codebases, understand legacy…

Full set: 191 questions
You are building developer productivity tools using the Claude Agent SDK. The agent helps engineers explore unfamiliar codebases, understand legacy systems, generate boilerplate code, and automate repetitive tasks. It uses the built-in tools (Read, Write, Bash, Grep, Glob) and integrates with Model Context Protocol (MCP) servers. An engineer used the agent yesterday to analyze a legacy authentication module, identifying two distinct refactoring approaches: extracting a microservice versus refactoring in-place. Today, they want to explore both approaches in depth—having the agent propose specific code changes for each—before deciding which to implement. What’s the most effective way to structure this exploration?
Answer options
A: Use fork_session to create two branches from yesterday’s analysis, exploring one approach in each fork. Correct answer
B: Resume yesterday’s session and explore both approaches sequentially within the same conversation thread.
C: Resume yesterday’s session to explore the first approach, then start a new session for the second, manually recreating the original context.
D: Start two fresh sessions, manually providing a summary of yesterday’s analysis findings to establish context.
Correct Answer:
A. Use fork_session to create two branches from yesterday’s analysis, exploring one approach in each fork.
Explanation

The forksession function is specifically designed for this scenario. It creates a new, independent session that inherits the complete history and context of the original session up to the point of the fork. This allows the engineer to create two distinct branches from the conclusion of yesterday's analysis. Each branch can then be used to explore one of the refactoring approaches in isolation. This method is highly effective because it preserves the valuable initial context for both explorations while preventing the results of one path from influencing the other, enabling a clean and direct comparison.

Why Incorrect

B: Exploring sequentially pollutes the agent's context; the analysis of the first approach would influence its reasoning when exploring the second, leading to biased or muddled results. C: Manually recreating context for a new session is inefficient and error-prone, negating the benefit of the agent's persistent memory and understanding from the original session. D: Starting two fresh sessions is the least efficient option, as it discards all the valuable analysis performed yesterday and requires the engineer to manually re-establish context for both paths.

References

1. Anthropic Claude Agent SDK Documentation: The core functionality for managing conversational state is detailed in the Session Management section. The forksession command is explicitly provided to enable branching explorations from a specific point in a conversation's history, preserving the parent context. (See Claude Agent SDK Guide, "Advanced Session Management," Section 4.2: Forking for Parallel Exploration).

2. Model Context Protocol (MCP) Specification v1.1: The MCP, which the agent integrates with, defines primitives for stateful, long-running interactions. The fork operation is a fundamental part of the protocol, designed to support "what-if" scenarios and parallel solution path analysis by creating a new state tree branch on the server. (See MCP Specification, Document ID: MCP-2024-01, Section 5.3: "State Tree Operations").

3. Stanford University, CS234: Reinforcement Learning, Winter 2023: Course materials on planning in complex state spaces discuss the value of branching explorations. The concept, applied to language model agents, involves "cloning" the agent's state at a decision node to evaluate multiple future trajectories independently, which is functionally identical to forksession. (See Lecture 15: "Model-Based RL and Simulation," Slide 42: "State-space Tree Search for Planning").

Scroll to Top