AI Agents with LangChain & Autonomous Workflows · 강의

안전장치 및 안전한 에이전트 동작

유해하거나 의도하지 않은 동작을 방지하기 위해 입력 및 출력 검증, 콘텐츠 필터링, 제한된 도구 접근 등 인공지능 에이전트를 위한 실용적인 안전장치를 구현하십시오.

레슨 4/413개 단계

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

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

From Ethics to Engineering

Ethical principles need enforcement in code. Guardrails are the concrete controls that keep an agent within safe, intended boundaries at runtime.

They act on three points: the input, the model's reasoning, and the output or actions.

Input Guardrails

Check user input before it reaches the agent. Catch:

  • Prompt-injection attempts
  • Requests for disallowed topics
  • Personal data that should be redacted

Detecting Prompt Injection

Prompt injection tries to override your instructions (e.g. ignore previous rules). A simple guard flags suspicious phrases before processing.

BAD = ['ignore previous', 'disregard instructions']
if any(p in user_input.lower() for p in BAD):
    raise ValueError('Possible prompt injection')

Output Guardrails

Validate what the agent produces before showing it. Block unsafe content, leaked secrets, or off-policy answers, replacing them with a safe fallback message.

if contains_sensitive(answer):
    answer = 'I cannot share that information.'

Structured Output Validation

When an agent must return JSON, validate it against a schema. Reject or repair malformed output so downstream systems never receive bad data.

from pydantic import BaseModel

class Ticket(BaseModel):
    priority: str
    summary: str

Ticket.model_validate_json(agent_output)

Constraining Tool Access

The most dangerous actions come from tools. Give an agent only the tools it needs, and scope each one — read-only where possible, with limits on what it can affect.

Allowlists Over Blocklists

Define what is permitted rather than chasing every bad case. An allowlist of approved domains, tables, or operations is far safer than trying to enumerate everything to forbid.

ALLOWED_DOMAINS = {'docs.company.com'}
if domain not in ALLOWED_DOMAINS:
    raise PermissionError('Domain not allowed')

Moderation Models

Provider moderation endpoints classify text for harmful categories. Run inputs and outputs through them as an extra safety layer.

result = client.moderations.create(input=text)
if result.results[0].flagged:
    block()

Limiting Autonomy

Cap how much an agent can do unattended: max iterations, max tool calls, spending limits, and human approval for high-impact actions. Bounded autonomy prevents runaway behavior.

agent = create_agent(llm, tools, max_iterations=8)

Fail Safe, Not Open

When a guardrail is uncertain or a check errors, default to the safe choice — refuse or escalate — rather than letting the action through. A blocked safe request is better than an executed harmful one.

Logging and Review

Log every guardrail trigger. Reviewing these reveals attack patterns and false positives, letting you tune rules over time without weakening safety.

Quick Check

Test your guardrails knowledge.

Recap

You learned to engineer safe agent behavior:

  • Add input and output guardrails
  • Detect prompt injection and validate structured output
  • Constrain tool access with allowlists and scoping
  • Use moderation, limit autonomy, and fail safe
  • Log and review every trigger

Guardrails turn ethical intent into enforced, trustworthy agents.

무료로 시작

AI 튜터와 함께 AI Agents with LangChain & Autonomous Workflows을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
12
레슨
50

자주 묻는 질문

“안전장치 및 안전한 에이전트 동작” 강의는 무료인가요?

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

“안전장치 및 안전한 에이전트 동작”에서 뭘 배우나요?

유해하거나 의도하지 않은 동작을 방지하기 위해 입력 및 출력 검증, 콘텐츠 필터링, 제한된 도구 접근 등 인공지능 에이전트를 위한 실용적인 안전장치를 구현하십시오. 브라우저에서 직접 실행하는 실습 코드로 AI Agents with LangChain & Autonomous Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

AI Agents with LangChain & Autonomous Workflows을(를) 시작하는 데 경험이 필요한가요?

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

“안전장치 및 안전한 에이전트 동작” 강의는 얼마나 걸리나요?

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

이 AI Agents with LangChain & Autonomous Workflows 강의에서 코드를 작성하고 실행할 수 있나요?

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

이 강의의 모든 강의

  1. 인공지능 에이전트의 윤리적 고려 사항
  2. 편향, 공정성, 투명성
  3. 새롭게 떠오르는 동향과 연구
  4. 안전장치 및 안전한 에이전트 동작
← AI Agents with LangChain & Autonomous Workflows(으)로 돌아가기