This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py --help |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py comprehensive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass | |
| from typing import List | |
| try: | |
| from strands import Agent | |
| from strands.tools import calculator, mem0_memory, tavily_search, tavily_extract, use_llm | |
| from strands.managers import SlidingWindowConversationManager | |
| except Exception: | |
| class Agent: | |
| def __init__(self, **kwargs): pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py research "Context engineering best practices" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import List, Optional | |
| from pydantic import BaseModel, Field | |
| class Answer(BaseModel): | |
| summary: str = Field(description="Brief summary of findings") | |
| bullets: List[str] = Field(description="Key points as bullet list") | |
| citations: List[str] = Field(description="Source URLs") | |
| uncertainty: Optional[str] = Field(default=None, description="Any uncertainty notes") | |
| def run_research_demo(query: str) -> Answer: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py route "Factor x^2 + 7x + 12" | |
| python strands_context_engineering_demo.py route "Why does my Python code raise a TypeError?" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pydantic import BaseModel, Field | |
| class RouteDecision(BaseModel): | |
| target: str = Field(description="Target specialist (math, code, generalist)") | |
| reason: str = Field(description="Why this target was chosen") | |
| confidence: float = Field(description="Confidence score (0.0-1.0)") | |
| def route_query(q: str) -> RouteDecision: | |
| ql = q.lower() | |
| if any(k in ql for k in ["factor", "integrate", "derivative", "+", "*", "^", "solve", "math"]): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py guard "My SSN is 123-45-6789" --shadow | |
| python strands_context_engineering_demo.py guard "My SSN is 123-45-6789" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def run_guardrails_demo(prompt: str, shadow: bool = True) -> None: | |
| """Pattern 4: Guardrails as Context Hygiene""" | |
| print(f"\nInput: {prompt!r}") | |
| print(f"Mode: {'Shadow (logging only)' if shadow else 'Enforcement'}") | |
| if shadow: | |
| print("Shadow mode: logging only (no enforcement).") | |
| print(f"Response: {prompt}") | |
| print("(Would log to monitoring system: PII pattern detected)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| python strands_context_engineering_demo.py research "Context engineering best practices" |
NewerOlder