0Pricing
Claude Architect · 강의

에이전트를 사용할 때

에이전트, 간단한 프롬프트, 고정 파이프라인의 차이를 알아봅니다

에이전트를 사용할 때은(는) CoddyKit의 무료 Claude Architect 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Claude Architect 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Three Ways to Solve a Task

Before you build anything with Claude, you make one key decision: how much autonomy does the task need? There are three patterns:

  • Simple prompt — one request, one reply.
  • Fixed pipeline — a known sequence of steps you wire up yourself.
  • Agent — the model decides which tools to call and when, looping until the work is done.

Picking the right one is an architecture decision. Over-build and you add cost and failure points; under-build and the task can't complete. This lesson teaches you to choose well.

The Simple Prompt

A simple prompt is a single API call: you send a system message plus messages, and you get one answer back. No tools, no loop.

Use it when the task is self-contained: rewriting text, summarizing a paragraph, classifying a sentence, answering a question from given context. If everything the model needs is already in the prompt, you don't need anything more.

Remember: the model keeps no state. Each call is independent — you must resend the full messages history yourself if you want continuity.

import anthropic

client = anthropic.Anthropic()

resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=512,
    system="You rewrite text to be clear and concise.",
    messages=[
        {"role": "user", "content": "Rewrite: 'The meeting, which was long, ended.'"}
    ],
)
print(resp.content[0].text)

The Fixed Pipeline

A fixed pipeline chains several steps in a known order. You — the architect — decide the sequence in code. Step 1 feeds step 2, which feeds step 3.

This is also called prompt chaining. Use it when the steps are known and sequential: extract fields, then validate them, then format a report. The model never chooses the path — you did, in advance.

Pipelines are predictable and easy to debug because the control flow is fixed. The trade-off is rigidity: they can't adapt when a task needs different steps depending on what they find.

# Fixed pipeline: each step's output feeds the next
extracted = extract_fields(document)        # step 1
validated = validate(extracted)             # step 2
report    = format_report(validated)        # step 3
# The sequence is hard-coded. The model never picks the path.

The Agent

An agent hands control flow to the model. You give Claude a goal and a set of tools, and the model decides which tool to call, inspects the result, and decides what to do next — looping until the goal is met.

The defining feature: decisions are model-driven, not hard-coded. You don't know in advance how many steps it will take or which tools it will use.

Use an agent when the path is open-ended: investigating a bug, researching a topic across sources, resolving a customer issue that might need a lookup, a refund, or an escalation depending on what's found.

resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    system="You are a support agent. Resolve the customer's issue.",
    tools=[get_customer, lookup_order, process_refund, escalate_to_human],
    messages=conversation,
)
# The model chooses which tool(s) to call based on the situation.

The Agentic Loop

An agent runs a loop driven by the response's stop_reason:

  • Send the request.
  • Inspect stop_reason.
  • If it is tool_use, run the requested tool(s), append the results to the message history, and send again.
  • Repeat until stop_reason is end_turn.

You terminate on the stop reason — the API's own signal that the turn is complete. This is the heart of every agent.

while True:
    resp = client.messages.create(model=MODEL, max_tokens=1024,
                                  system=SYSTEM, tools=TOOLS,
                                  messages=messages)
    messages.append({"role": "assistant", "content": resp.content})

    if resp.stop_reason == "end_turn":
        break                       # task complete
    if resp.stop_reason == "tool_use":
        results = run_tools(resp.content)
        messages.append({"role": "user", "content": results})

Never Parse Text for 'Done'

A common and dangerous mistake: ending the loop by scanning the model's reply for words like "done" or "finished". The model might say "done" mid-thought, or never say it at all. This is a classic anti-pattern.

Always terminate on the stop_reason — end_turn means complete. The stop reason is a structured, reliable signal; free text is not.

Iteration caps (a maximum loop count) are a safety net to prevent runaway loops — never the primary stop mechanism. The real stop is always the stop reason.

# ANTI-PATTERN: do not do this
if "done" in resp.content[0].text.lower():
    break

# CORRECT: rely on the structured stop reason
if resp.stop_reason == "end_turn":
    break

Decision Rule: Is the Path Known?

Here is the single question that decides agent vs pipeline:

Do you know the steps in advance?

  • Yes, fixed and sequential → use a fixed pipeline (prompt chaining). It is cheaper, faster, and easier to debug.
  • No, open-ended investigation → use an agent with adaptive decomposition.

If a task needs no external data or actions at all and fits in one call, you don't even need a pipeline — a simple prompt is enough. Always reach for the simplest pattern that does the job.

Decisions vs Guarantees

Agents are powerful because the model decides — but model decisions are probabilistic (roughly 90% reliable), not certain. So a second rule applies:

Let the model decide; reserve hard code for guarantees.

When a wrong action has financial, legal, or safety consequences — like a large refund — you do not rely on a prompt. You enforce the rule deterministically with a hook or a programmatic precondition. Prompts guide; hooks guarantee.

So an agent is the right shape and critical rules are still enforced in code around it. The two are not in conflict.

# Prompt guidance is ~90% reliable — fine for routine routing.
# A hook is 100% deterministic — use it for critical rules:
#   block process_refund when amount > 500
#   block process_refund until get_customer returns a verified ID
# Outgoing-call hooks reject policy-violating actions before they run.

When a Pipeline Beats an Agent

Don't reach for an agent just because it feels modern. A fixed pipeline wins when:

  • The sequence of steps is known and stable.
  • You want predictable cost and latency (no open-ended looping).
  • You need control flow that is easy to test and debug.

Example: structured data extraction where you always extract, then validate, then format. The path never changes, so hard-coding it is the correct, robust choice. Adding agent autonomy here only adds nondeterminism and cost for no benefit.

When an Agent Is the Right Call

Choose an agent when the work is genuinely open-ended and the path depends on what is discovered along the way:

  • Bug investigation — grep entry points, read files, follow usages; you can't script the route in advance.
  • Multi-source research — a coordinator decomposes the question and delegates to subagents.
  • Customer support — one issue needs a lookup, another a refund, another an escalation.

In all of these, the next step depends on the last result. That dependency is exactly what an agentic loop handles and a fixed pipeline cannot.

system=("You are a debugging agent. Investigate the failing test "
        "and find the root cause.")
tools=[glob_tool, grep_tool, read_tool, bash_tool]
# The model adapts: Grep entry points -> Read files -> Grep usages
# -> Read consumers. The route is decided at runtime, not by you.

A Practical Checklist

Run any new task through this quick checklist:

  • One self-contained call? → simple prompt.
  • Known, fixed sequence of steps? → fixed pipeline.
  • Open-ended, path depends on results? → agent.
  • Critical rule (money / legal / safety)? → enforce it with a hook, whichever pattern you chose.

Default to the simplest pattern that works. Add autonomy only when the task truly needs it — and add deterministic enforcement wherever a mistake would be costly. That balance is what separates an architect from a tinkerer.

Quick Check

Test your decision-making on a realistic scenario.

Recap: Choosing Your Pattern

Key takeaways:

  • Simple prompt — self-contained, one call, no state (resend full history yourself).
  • Fixed pipeline — known, sequential steps; predictable, cheap, easy to debug.
  • Agent — open-ended path the model decides at runtime via the agentic loop.
  • The loop terminates on stop_reason == end_turn, never by parsing text; iteration caps are only a safety net.
  • Model decisions are probabilistic; enforce critical money/legal/safety rules with hooks or programmatic preconditions for deterministic guarantees.
  • Default to the simplest pattern that does the job.

Master this choice and the rest of agent architecture builds cleanly on top of it.

자주 묻는 질문

“에이전트를 사용할 때” 강의는 무료인가요?

네 — “에이전트를 사용할 때” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Claude Architect 강의 전체를 잠금 해제할 수 있습니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.

“에이전트를 사용할 때”에서 뭘 배우나요?

에이전트, 간단한 프롬프트, 고정 파이프라인의 차이를 알아봅니다 브라우저에서 직접 실행하는 실습 코드로 Claude Architect을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Claude Architect을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Claude Architect은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“에이전트를 사용할 때” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Claude Architect 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Claude Architect 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 시스템을 에이전트답게 만드는 요소
  2. 모델 기반 결정과 하드코딩된 결정
  3. 에이전트를 사용할 때
  4. 에이전트 루프 개요
← Claude Architect(으)로 돌아가기