Sub topic 1
What a Model Call Actually Does
Prerequisites
You should know basic Python or JavaScript, JSON, HTTP APIs, and command-line tools. You should also understand that a large language model generates text from input tokens.
What a Model Call Actually Does
A model call is one request to a language model. The model receives structured input and returns a response. It does not permanently remember earlier calls. The application must send the relevant conversation again on every request.
A coding agent adds a harness: a program that stores messages, calls the model, executes requested tools, and sends the results back.
Messages and Roles: How a Conversation Is Sent
Messages usually contain a role and content. Common roles are:
system: global behavior and limits.user: the task or question.assistant: the model's previous response.tool: output produced by an external tool.
The message list is the model's working conversation. The harness appends each assistant response and tool result before making the next call.
The Context Window: The Model's Entire Working Memory
The context window is the maximum amount of input and output the model can handle for one call. It includes instructions, conversation history, tool definitions, source code, and tool results.
Long command output or repeated file contents can consume this space. When the history approaches the limit, the harness can search for only relevant text, truncate low-value output, or summarize older messages. A context estimate is useful, but token counts should use the provider's tokenizer when precision matters.
System Prompt and Project Instructions
A system prompt establishes high-level behavior. Project instructions add repository-specific rules, such as coding style, test commands, or files that must not be changed. The harness places these instructions in the model's input, so they consume context and should be concise.
Defining Tools: Names, Descriptions, and Schemas
A tool definition tells the model what an operation does and which arguments it accepts. Its input schema is a JSON Schema contract. The model proposes a call; the harness validates the arguments and runs the implementation.
{
"name": "read_file",
"description": "Read a UTF-8 text file from the workspace.",
"input_schema": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path relative to the workspace root"
}
},
"required": ["path"],
"additionalProperties": false
}
}A precise description improves tool selection, while schema validation prevents malformed arguments from reaching the implementation.
Exercise
Why must an agent harness resend earlier messages on each model call?
Show answer
The model call is stateless. The harness must resend the conversation and relevant results to provide continuity.