Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
257 Following    203 Followers
# OpenCode Features and Practical Usage 🧰 Wish you could decide in one line what your AI agent is allowed to do and what it must never touch? OpenCode's built-in tools plus permissions give you exactly that. 🏷️ Title: Built-in Tools + Permissions 🔗 URL: 📘 Overview OpenCode agents act on your codebase through "tools" such as file editing and shell execution. A rich set ships by default, and each tool can be governed by an allow / ask / deny policy. You get the safety-versus-convenience balance tuned entirely from config. ⚙️ How It Works The main built-in tools are: ・`bash`: run shell commands (git, npm, etc.) ・`edit`: modify existing files via exact string replacement ・`write`: create or overwrite files ・`read`: read files, with optional line ranges ・`grep`: regex search across files ・`glob`: find files by patterns like `**/*.js` ・`webfetch` / `websearch`: fetch and search the web ・helpers like `lsp`, `apply_patch`, `skill`, `todowrite`, `question` Permissions are set in the `permission` field with three states: `allow` (run freely), `ask` (confirm each time), `deny` (forbidden). Note that the `edit` permission governs `edit`, `write`, and `apply_patch` together. 🛠️ Practical Usage In `opencode.json`, you can forbid edits, confirm every bash call, and allow web fetches freely — set `"edit": "deny"`, `"bash": "ask"`, and `"webfetch": "allow"` under the `permission` block. Tools coming from MCP servers can be controlled with wildcards. Writing `"mymcp_*": "ask"` requires confirmation for every tool from that server. 💡 Use Cases On a production-adjacent repo, set `edit` to `deny` and `bash` to `ask` so the agent can plan and investigate but cannot rewrite code or run destructive commands on its own. On a throwaway experiment branch, allow everything to move fast. Switching between the two is just a config change. ⚠️ Caveats By default all tools are allowed, so nothing is restricted until you explicitly narrow it. The `lsp` tool needs `OPENCODE_EXPERIMENTAL_LSP_TOOL=true`, and `websearch` (powered by Exa) needs `OPENCODE_ENABLE_EXA=1`. It is easy to forget that the `edit` permission also covers write and apply_patch. #OpenCode# #AIAgents#
Show more
# Hermes Agent Features and Practical Usage 🚀 Pick up exactly where you left off with a single command. Hermes Agent Sessions automatically record, resume, and search every conversation, forming the backbone of long-running agent operation. 📌 Title and Feature URL Title: Sessions URL: 📝 Overview Sessions automatically save every interaction, whether from CLI, Telegram, Discord, Slack, or other platforms. Full message history is persisted to SQLite, so you can resume past work or surface old exchanges via full-text search. Because sessions are tracked per platform, each chat naturally keeps its own context. 🔧 How It Works - History lives in `~/.hermes/state.db` (SQLite, WAL mode), tracking metadata, full message history, token counts, and an FTS5 full-text search index. - Only the current conversation window loads into active context, not every historical byte. Images become descriptions, audio is transcribed, and documents are summarized rather than re-sent. - After the first exchange, a background auxiliary model auto-generates a descriptive 3-7 word title with no added latency. - Sessions are keyed deterministically by source, with distinct formats for DMs, groups, and threads. 🛠 Practical Usage - Resume the latest CLI session: `hermes --continue` (or `-c`); resume by title with `hermes -c "project name"`, or by ID with `hermes --resume `. - List/export/manage: `hermes sessions list --limit 50 --source telegram`, `hermes sessions export backup.jsonl`, `hermes sessions prune --older-than 90 --yes`, `hermes sessions stats`. - Manual naming: `/title my project` in chat, or `hermes sessions rename "new title"`. - The agent itself uses the `session_search` tool (FTS5) and auto-references past chats when you say things like "remember when." - Hand off an active CLI conversation to a messaging platform with `/handoff telegram`, preserving the full transcript. 🎯 Use Cases - Resume yesterday's refactor with all prior context intact. - Quickly recall "what did we decide back then" via full-text search. - Keep separate context per entry point (Telegram, Discord) to avoid crosstalk. - Use it as a work-history database for long-running agents. ⚠️ Caveats - Auto-titling runs only once per session and skips if a title already exists. - Media bytes are never re-sent; only derived text or file paths persist in later context. - Auto-pruning (` is disabled by default; active sessions are never pruned regardless of age. - On non-thread platforms with shared group home channels, genuinely shared group chats aren't handled ideally. #HermesAgent# #AIAgents#
Show more
# Practices for Embedding AI Agents in Software # Read-Free / Write-Gated 🎯 The Hook Approving every single tool call is a recipe for approval fatigue, where the rubber-stamp on a dangerous write operation is just one click away. Separate reads from writes and focus human attention where it matters. 🔥 The Problem Agents mix side-effect-free reads with irreversible writes. Gating everything equally drowns humans in approval requests. Since reads dominate most workloads, approval fatigue sets in fast, and the critical write approvals get waved through without scrutiny. Remove all gates, though, and you risk irreversible damage from unchecked writes. 💡 The Pattern Split tool calls into "read" (search, fetch, reference) and "write" (create, update, delete, send). Let reads flow freely while gating writes with authorization, validation, approval, and audit. Classify R/W statically at tool registration time in code, never by LLM judgment. Graduate write gate strictness by reversibility: irreversible operations like email sends or payments require human approval, while reversible ones like draft saves pass through policy validation only. This dramatically reduces approval fatigue while maintaining safety for side effects. ✅ When to Use Use when: - Read and write operations are mixed, with reads making up the majority - Irreversible writes exist (email sends, payments, production DB changes) - You need to preserve human review bandwidth for high-risk operations Don't use when: - Reads themselves access sensitive data (PII lookups, confidential documents) and need authorization too - All operations are read-only with no writes at all - It's an experimental environment where all operations are reversible and low-cost ⚠️ Pitfalls - Never let the LLM classify read vs. write. Injection can make it label a write tool as "read," bypassing the gate entirely - Watch for "reads with side effects" like API call counters or view history tracking - Applying the same gate strictness to reversible and irreversible writes brings approval fatigue right back 🔧 Implementation Approach - Assign type (read/write) and gate mode (none/auto/human_approval) statically at tool registration, making it structurally impossible for the LLM to reclassify at runtime - Implement the write path as a pipeline of input validation, gate evaluation, execution, and full audit logging, while reads log only metadata - Graduate write gate strictness using a reversibility flag, combining irreversible operations with mandatory dry-run as a prerequisite - Enforce all gate logic in deterministic code at the gateway layer, with zero reliance on prompt-based access control #AIAgents# #SoftwareArchitecture#
Show more
# Useful but Little-Known Features of Claude Agent SDK 🌍 Need to change permissions mid-session? You can dynamically switch permission modes during streaming! Claude Agent SDK lets you call `set_permission_mode()` to instantly change the permission mode while a session is running. 📌 Title: Dynamic Permission Mode Changes During Streaming 🔗 URL: 🧩 Overview Using `set_permission_mode()` (Python) or `setPermissionMode()` (TypeScript), you can change the permission mode in real-time during an active session. The new mode takes effect immediately for all subsequent tool requests. This enables progressive trust workflows where you start restrictive and loosen permissions as confidence builds, for example switching from `default` to `acceptEdits` after reviewing Claude's initial approach. 🛠 How to Use ```python # Python - progressively relaxing permissions import asyncio from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions async def main(): async with ClaudeSDKClient( options=ClaudeAgentOptions( permission_mode="default", # Start in default mode ) ) as client: await client.query("Refactor this code") # After reviewing the approach, allow edits await client.set_permission_mode("acceptEdits") async for message in client.receive_response(): if hasattr(message, "result"): print(message.result) ``` ```typescript // TypeScript const q = query({ prompt: "Refactor this code", options: { permissionMode: "default" } }); // After reviewing the approach, allow edits await q.setPermissionMode("acceptEdits"); for await (const message of q) { if ("result" in message) console.log(message.result); } ``` 🏗 Integration into Production Systems - Implement "plan, review, then acceptEdits" workflows for safe step-by-step automation - Build interactive apps that progressively expand permissions based on user trust and task progress - Use as a "fallback" pattern to tighten permissions when errors are detected - Integrate with monitoring systems to automatically switch to restrictive modes on anomaly detection 💡 Use Cases 🔐 Interactive workflows that grant edit permissions only after code review approval 📈 Progressive automation that expands permissions as the task advances 🛡 Defensive agents that instantly switch to restrictive mode upon detecting anomalies ⚠️ Caveats - The new mode takes effect immediately, so be careful about the timing of the switch - Mode changes are only effective within the current session - Switching to `bypassPermissions` or `auto` mode will be inherited by subagents ✨ Dynamic permission changes enable "start safe, flex as needed." Build progressive trust workflows to get the best of both safety and productivity! #ClaudeAgentSDK# #AIAgent#
Show more
# Practical ways to use the Claude Agent SDK 🤖 Delegate specialized tasks to sub-agents and keep your main context lean. Sub-agents delegate specific subtasks to specialized agents, enabling parallel and expert processing without polluting the main agent's context. 📌 Title: Sub-agents in the SDK 🔗 URL: 🧩 Overview Define specialized agents via the `agents` parameter. The main agent calls them through the `Agent` tool. Each sub-agent gets its own prompt, tool restrictions, and model settings. Results return as summaries to the main agent. 🛠 How to use it Define sub-agents in the `agents` parameter using `AgentDefinition` with `description`, `prompt`, `tools`, and `model`. Include `"Agent"` in `allowed_tools` to auto-approve sub-agent invocations. Each sub-agent gets its own tool restrictions, prompt, and model settings. 🏗 Practical usage - Delegate large file exploration to a `research-assistant` sub-agent, returning only summaries to the parent. Keeps main context lean. - Run `style-checker` / `security-scanner` / `test-coverage` concurrently, reducing code review time from minutes to seconds. - Give a `database-migration` sub-agent SQL best practices and rollback strategies in its prompt for expert handling. - Use factory functions to dynamically select `model: "opus"` vs `sonnet` based on runtime conditions. 💡 Use cases 🔍 Delegating large-scale file exploration ⚡ Parallel code review (style/security/coverage) 🎯 Expert task splitting across specialized agents ⚠️ Watch out Sub-agents cannot spawn their own sub-agents (one level only). For large-scale orchestration, use the `Workflow` tool (TS v0.3.149+). Capture `agentId` and `session_id` for follow-up via `resume`. #ClaudeAgentSDK# #AI#
Show more
A useful but little-known Gemini API feature 🔄 Some workloads don't need blazing-fast responses. Why pay premium prices for them? Gemini's "Flex inference" is a lower-cost inference tier with variable latency. It's the right pick when cost efficiency matters more than real-time speed. 📌 Title: Flex inference 🔗 URL: 🧩 Overview The standard inference tier prioritizes stable latency, but not every task needs that. Flex inference uses spare capacity to process your requests at a lower price, with the trade-off of variable response times. It sits in the sweet spot between the Batch API (cheapest but slowest) and the standard tier (fast but full price). 🛠 How to use it Specify Flex as the inference tier in your request. The API call format and response format are identical to the standard tier, so the only code change is adding the tier parameter. Test the latency range in your specific use case before rolling it out to production. 🏗 Building it into production ・Back-office processing: internal summarization, classification, or tagging tasks where no user is staring at a loading spinner. ・Async workers: queue-based workers that pull tasks and can tolerate some delay in processing. ・Dev/staging environments: run large volumes of requests during testing and experimentation without worrying about cost. ・Draft content generation: producing drafts or outlines that won't be published immediately. 💡 Use cases 📋 Internal, non-real-time processing 🔧 Async queue-based worker tasks 🧪 High-volume experiments in dev/test environments 📝 Pre-publish draft and outline generation ⚠️ Watch out Variable latency makes this a poor fit for user-facing UIs where someone is waiting for a response (chatbots, etc.). Latency can spike during peak times, so if you need SLAs, Priority inference is the better choice. The actual cost savings depend on your usage pattern, so measure before committing. ✨ Not every request needs top-speed inference. Identify where cost matters more than speed, and let Flex handle those smartly. #Gemini# #LLM#
Show more
# Cursor Features and Practical Usage 🧩 Tired of re-explaining the same multi-step workflow to your agent every single time? Cursor Skills let you package repeatable workflows so the agent just knows how to do them. 🏷️ Title: Reusable Workflows (SKILL.md) 🔗 URL: 📘 Overview Skills are portable, version-controlled packages that teach agents how to perform domain-specific tasks. They bundle scripts, templates, and reference material that the agent runs through its available tools. They are the evolution of Rules: agents can apply them automatically based on context, or you can invoke them explicitly as slash commands. ⚙️ How It Works Each skill is centered on a `SKILL.md` file whose leading YAML frontmatter defines its behavior. ・`name`: a lowercase identifier that must match the parent folder name (required) ・`description`: what the skill is for and when it applies; the agent reads this to decide whether to use it (required) ・`paths`: glob patterns that scope the skill to matching files (optional) ・`disable-model-invocation`: set to `true` to make it slash-only, included only when you type `/skill-name` (optional) Discovery is hierarchical: project skills live in `.cursor/skills/` (or `.agents/skills/`), and global ones in `~/.cursor/skills/`. The root is walked recursively, so nested subdirectories are found too. A skill folder can also ship `scripts/` (executable code), `references/` (docs loaded on demand), and `assets/` (templates or images). 🛠️ Practical Usage For example, in `.cursor/skills/api-endpoint/SKILL.md` set the frontmatter `name` to `api-endpoint`, a `description` of the workflow, and `paths` scoped to `src/api/**/*.ts`, then write the steps in the body (register the route, validate input with a zod schema, always add tests). If you do not want automatic invocation, add `disable-model-invocation: true` and call it explicitly by typing `/api-endpoint` in Agent chat. 💡 Use Cases In a monorepo, placing a `.cursor/skills/` folder inside each app automatically scopes those skills to files in that directory, so you can skip `paths` entirely. Share release procedures, migration scripts, or code-review checklists so the whole team works the same way. You can convert existing assets with the built-in `/migrate-to-skills` (Cursor 2.4): "Apply Intelligently" rules (`alwaysApply: false`) become skills, and slash commands become skills with `disable-model-invocation: true`. ⚠️ Caveats A skill's identity comes from the folder containing `SKILL.md`, not any parent category. The old `globs` field is deprecated; use `paths` now. `/migrate-to-skills` does not migrate `alwaysApply: true` rules or user-level rules, so those need manual handling. #Cursor# #AICoding#
Show more
# Useful but Little-Known Features of ADK 2.0 🌍 Sending the same system prompt and tool definitions to the LLM on every call wastes both money and time. What if the SDK could cache that for you? ADK 2.0's ContextCacheConfig caches repeated context data sent to the LLM, reducing both API costs and response latency. Available with Gemini 2.0+, Python v1.15.0+, and Java v0.1.0+. 📌 Title: Context Cache (ContextCacheConfig) 🔗 URL: 🧩 Overview ContextCacheConfig reduces token consumption by caching context sent to the LLM — system prompts, tool definitions, fixed portions of conversation history, and more. It has three key parameters: min_tokens sets the minimum token threshold for caching to activate (default 0), ttl_seconds controls cache lifetime (default 1800 seconds / 30 minutes), and cache_intervals limits maximum cache reuse count (default 10). Configure it on the App object and caching is applied automatically. 🛠 How to use it Create a ContextCacheConfig and set it on the App. ```python from import App from google.adk.context import ContextCacheConfig cache_config = ContextCacheConfig( min_tokens=1000, # Cache only when context >= 1000 tokens ttl_seconds=3600, # Keep cache for 1 hour cache_intervals=20, # Reuse up to 20 times ) app = App( agent=my_agent, context_cache_config=cache_config, ) ``` Setting min_tokens appropriately ensures that small contexts are sent normally while large contexts benefit from caching. 🏗 Building it into production ・Agents with large system prompts or many tool definitions benefit the most from caching ・Tune ttl_seconds to match your workload pattern (short conversations → shorter TTL, long ones → longer TTL) ・Adjust cache_intervals based on request frequency to balance freshness and cost savings ・Monitor cost reduction metrics and continuously optimize parameters 💡 Use cases 💰 Cut API costs for agents with large, stable system prompts ⚡ Reduce response latency by skipping repeated tool definition transmission 🔁 Optimize token consumption for high-frequency chatbot interactions 📋 Efficiently handle fixed context (rules, guidelines, policies) that rarely changes ⚠️ Watch out This feature requires Gemini 2.0 or later. Context changes won't take effect while a cache is active, so set a shorter ttl_seconds if you frequently update system prompts. When cache_intervals is exceeded, a new cache is created, which can cause cost optimization effects to fluctuate. ✨ Context caching delivers significant cost and performance improvements, especially in scenarios with large, frequently-accessed context. It's a quick win for production deployments. #ADK# #AIAgent#
Show more
# Neo4j Features and Practical Usage 🚪 Pick the wrong data-import method up front and every downstream step pays for it. Neo4j's "Import your data" hub helps you choose the right entry point based on scale and frequency. 🏷️ Title: Import method selection guide 🔗 URL: 📘 Overview Neo4j offers several ways to load data, each with different strengths in terms of scale, execution mode (online vs offline), and permission requirements. This page is not a step-by-step tutorial but a decision hub for choosing the right method before you start. ⚙️ How It Works The main options are: ・Data Importer: a browser-based GUI where you drag and drop CSVs and visually map columns to nodes and relationships. No Cypher required; ideal for testing and prototyping. ・`LOAD CSV`: a general-purpose Cypher-based loader. Runs online (database stays up) and is usable by non-admin users. Good up to hundreds of thousands or low millions of rows. ・`neo4j-admin database import`: an offline bulk loader that writes directly to the native store format, making it the fastest path for initial loading of very large datasets (billions of entities). ・Connectors / APOC: continuous sync via Apache Spark, Kafka, and CDC, plus support for diverse formats like JSON, XML, and XLS. 🛠️ Practical Usage Decide the entry point by scale and frequency: ・A few thousand master records, fast → Data Importer (GUI) ・Millions of rows on a schedule / incremental → `LOAD CSV` (made idempotent with `MERGE`) ・Billions of entities, one-shot initial build → `neo4j-admin database import` (offline) ・Always-on continuous sync → Kafka / CDC / Spark connectors Whatever the path, a shared best practice is to create a uniqueness constraint on the key column before importing. ```cypher CREATE CONSTRAINT person_id IF NOT EXISTS FOR (p:Person) REQUIRE IS UNIQUE; ``` 💡 Use Cases Early in a project, split the paths: Data Importer for the PoC, `neo4j-admin import` for the production initial build, and `LOAD CSV` for daily incrementals. This keeps validation light and fast while making the bulk load as fast as possible. ⚠️ Caveats ・`neo4j-admin import` targets an empty database and runs offline, so it cannot be used against a live database. ・`LOAD CSV` tends to hit memory issues as row counts approach hundreds of thousands to millions; split work with `CALL { } IN TRANSACTIONS`. ・Continuous sync (Kafka/CDC) is distinct from initial loading and should be designed alongside it. ・This page is just the entry point; confirm the details of each method in its dedicated docs. #Neo4j# #DataImport#
Show more
Practices for embedding AI agents into enterprise systems [Supervisor / Router] 💡 The key to "ask anything" enterprise AI is smart traffic control behind the scenes. A lightweight classifier instantly routes requests to the right domain agent. 🔥 Problems Solved - Cramming all capabilities into one giant prompt degrades quality - Cannot use optimized prompts, tools, and models per domain - Processing every request with the most powerful model breaks the budget - Unclassifiable requests get lost with no fallback 🏗️ Proposed Pattern A cheap, fast classifier determines user intent and delegates to specialized agents for sales, IT, HR, engineering, and more. Ambiguous inputs trigger clarification questions before routing. Each delegation carries permission caps, cost limits, and timeouts to prevent runaway behavior. A fallback route to a default agent or human escalation is always required for unclassifiable requests. ✅ Selection Criteria - Fit: company-wide deployments covering diverse operations, environments with multiple domain agents - Not Fit: single-domain agents where routing is unnecessary ⚠️ Pitfalls - Underestimating misrouting cost (sending complex tasks to small models tanks quality) - Relying on static rules without measuring classification accuracy fails as business evolves - Missing fallback routes cause unknown requests to loop endlessly 🛠️ Implementation Approach 1. Use a fine-tuned lightweight model (e.g., distilBERT) or rule-based classifier for intent classification to minimize latency and cost 2. Manage the routing table in a config file (YAML/JSON) so domain agents can be added or changed without code modifications 3. Always implement a fallback route -- either a default agent or human escalation via Slack -- for unclassifiable requests 4. Pass permission caps, cost limits, and timeouts as parameters to delegate agents, with policies centrally managed via OPA/Cedar 5. Continuously measure classification accuracy through A/B testing and weekly reports, retraining the classifier based on misrouting rates #AIAgents# #EnterpriseArchitecture#
Show more
A useful but little-known Claude API feature 📁 Tired of re-encoding and re-sending the same file as Base64 with every request? Upload once, use many times. Claude's Files API lets you upload files and reference them across multiple requests. No more redundant file transfers, saving both cost and latency. 📌 Title: Files API 🔗 URL: 🧩 Overview When you need Claude to process images, PDFs, or text files, the traditional approach is sending Base64-encoded file data with every request. Files API lets you upload a file once, get a file_id, and reference it by ID in subsequent requests. This cuts transfer overhead and pairs well with Prompt Caching. 🛠 How to use it Upload a file via the Files API and save the returned file_id. In the Messages API, reference the file using a file_id content block. When asking multiple questions about the same file or processing it with different prompts, you never need to resend the file data. 🏗 Building it into production ・Document analysis services: store a user-uploaded PDF once and run multiple analyses (summary, QA, data extraction) sequentially without resending the PDF each time. ・Image analysis pipelines: pre-upload batches of images and process them in bulk, cutting transfer cost and latency significantly. ・Multi-turn document chat: upload reference documents once and ask questions against them repeatedly in an interactive QA session. ・Template management: save boilerplate documents or style guides as files and reference them across generation requests. 💡 Use cases 📄 Repeated analysis of PDFs and documents 🖼 Batch image processing 💬 Document-based multi-turn chat 📋 Reusable template files ⚠️ Watch out Uploaded files have retention limits, so check expiration for long-term references. File size limits also apply. For managing many files, build a lifecycle management system for file_ids. ✨ Paying to transfer the same file over and over is pure waste. Upload once, reference by ID, and improve both cost and developer experience. #Claude# #LLM#
Show more
# Practical and Useful Patterns with ADK ✋ "Are you sure you want to send this email?" — ADK's Action Confirmations add pre-execution user approval for irreversible operations, building safer agents. 📌 Title: Action Confirmations — Pre-Execution Approval for Irreversible Operations 🔗 URL: 🧩 Overview ADK's Action Confirmations require explicit user approval before executing hard-to-reverse operations like email sending, data deletion, and payment processing. The agent asks "Should I proceed?" and only executes upon user approval. This maintains human control at critical decision points while keeping agents autonomous for routine tasks. 🛠 Usage Defining tools with confirmation requirements. To define tools with confirmation, import `Agent` and `ToolContext` from `google.adk`. In `send_email(to: str, subject: str, body: str, tool_context: ToolContext)`, call `tool_context.actions.request_confirmation(message=...)` before the actual send, displaying a preview with recipient, subject, and body. The email is only sent if the user approves. Similarly, `delete_records(table: str, condition: str, tool_context: ToolContext)` counts records to be deleted first, then displays the count in a confirmation message for user approval. Pass both tools to an `Agent` with `name="admin_assistant"` and `model="gemini-2.5-flash"` via the `tools` parameter. 🏗 Practical Patterns **When to Require Confirmation**: Add confirmation for these categories: - External sends (email, messages, API calls) - Data modification or deletion - Operations that incur charges - Permission or access control changes For payment processing, define `process_payment(amount: float, currency: str, recipient: str, tool_context: ToolContext)`. This function calls `tool_context.actions.request_confirmation(message=...)` with the recipient, currency, and amount details. Only after user approval does it execute `payment_gateway.charge(amount=..., currency=..., recipient=...)` to process the transaction. **Confirmation Message Design**: Include the target, scope of impact, and irreversibility in confirmation messages. Provide exactly the information users need to make an informed decision. **Staged Confirmations**: For multi-step operations, decide whether to confirm at each step or summarize at the final step. Balance thoroughness with user experience. 💡 Use Cases 📧 Email and message send confirmation 🗑️ Database record deletion approval 💳 Payment and transfer execution confirmation 🔐 Permission and access control change approval ⚠️ Caveats - Too many confirmations degrade user experience. Limit confirmations to truly irreversible operations. - Insufficient confirmation messages prevent users from making informed decisions. Be specific about the operation's impact. - Confirmations become bottlenecks in batch processing and automation pipelines. Consider skippable confirmations for automated scenarios. ✨ Properly configured Action Confirmations balance agent autonomy with human safety oversight. The key is confirming only "can't-undo" operations! #ADK# #AIAgent#
Show more
# Weaviate Features and Practical Usage 🚀 Ever wished you could delete all the embedding-API plumbing from your app code? Weaviate's model provider integrations let you wire up vectorization, generation, and reranking just by writing it into your collection config. 📌 Title and Feature URL Title: Model provider integrations URL: 📝 Overview Weaviate integrates with 20+ model providers including OpenAI, Cohere, Google, AWS, Azure OpenAI, Mistral, Anthropic, Hugging Face, and Ollama. You can plug them into automatic embedding at import, automatic embedding of query text, generation for RAG, and reranking of search results. The big win is that your application no longer needs code to call an embedding API and pass vectors in. 🔧 How It Works Integrations fall into three roles: - Vectorizer (embeddings): text or multimodal vectorization. - Generative (LLM): text generation for RAG pipelines. - Reranker: result refinement (offered by Cohere, Jina AI, NVIDIA, Voyage AI). There are also two delivery forms. API-based providers (OpenAI, Google, Cohere, AWS Bedrock, etc.) call external services, while locally hosted options (Ollama, Hugging Face Transformers, Model2vec) run on your own infrastructure. API-based modules are enabled by default in v1.33+. 🛠 Practical Usage - Specify an embedding provider with Configure.Vectors at collection creation, and Weaviate vectorizes automatically at both import and query time. - Configure generation with Configure.Generative to run RAG over your search results. - Configure a reranker with Configure.Reranker. - Automatic vectorization targets text / text[] properties. Weaviate sorts property names alphabetically, concatenates them, optionally prepends the collection name, and sends the string to the model (you can also exclude properties per-field). 🎯 Use Cases - Internal document search: auto-vectorize body text at import, and auto-vectorize the query with the same model so they stay consistent. - Model swapping: change vendor or model by editing collection config only. - Closed-network requirements: use a locally hosted option like Ollama to keep data in-house through embedding generation. - RAG chat: combine retrieval and generation within the same configuration, minimizing external orchestration. ⚠️ Caveats - API-based providers require API keys and incur usage charges. - Rate limits follow each provider's policy; watch out during bulk imports. - For versions before v1.27, the concatenated string is lowercased before being sent to the model. - For versions before v1.33, set ENABLE_API_BASED_MODULES to use API-based modules. #Weaviate# #Embeddings#
Show more
A useful but little-known OpenAI API feature 📊 Manually checking every model output for quality? There's a way to automate that. OpenAI's "Graders" automatically score model outputs. Use them for quality evaluation in Evals or as reward functions for reinforcement fine-tuning. 📌 Title: Graders 🔗 URL: 🧩 Overview Improving model quality requires a way to quantitatively judge what's good and what's bad. Graders are automatic scoring functions that evaluate model outputs. They support multiple methods: string matching, model-based judgment, custom Python code evaluation, and more. Use them in Evals pipelines for quality measurement or as reward functions for reinforcement fine-tuning. 🛠 How to use it Choose a scoring method and define your evaluation criteria. Options range from simple string matching and label checking to complex quality assessments using another LLM as a judge. Plug the grader into your Evals pipeline or use it as a reward signal for reinforcement fine-tuning. 🏗 Building it into production ・Continuous quality monitoring: sample production outputs and auto-score them with graders. Catch quality degradation early. ・Evals pipelines: quantitatively compare quality when changing prompts or updating models. ・Reinforcement fine-tuning: use grader scores as rewards to improve models through reinforcement learning. ・A/B test evaluation: compare outputs from different prompts or models using graders as the evaluation backbone. 💡 Use cases 📈 Continuous quality monitoring of model outputs 🧪 Quantitative quality comparison in Evals 🎯 Reward design for reinforcement fine-tuning 🔬 A/B testing of prompts and models ⚠️ Watch out The quality of your graders determines the reliability of your evaluations. Model-based graders in particular can produce inconsistent scores if the criteria are vague. Define clear, specific evaluation criteria and calibrate against human judgments to keep grading trustworthy. ✨ Quality improvement starts with measurement. Plug graders into your Evals pipeline and start quantifying output quality today. #OpenAI# #LLM#
Show more
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Want to manage and version your prompts on the platform instead of hardcoding them? With Prompt Templates, you can reference prompts created on the OpenAI platform from the SDK, injecting variables dynamically. 📌 Title: Prompt Templates 🔗 URL: 🧩 Overview Instead of `instructions`, you can use the `prompt` parameter to reference prompt templates created and managed on the OpenAI platform. For static usage, pass a dict like `{"id": "pmpt_123", "version": "1", "variables": {...}}`. For dynamic usage, pass an async function that returns a prompt dict at runtime, enabling context-dependent variable injection. 🛠 How to use it ```python from agents import Agent, RunContextWrapper # Static template reference agent_static = Agent( name="support", prompt={ "id": "pmpt_abc123", "version": "1", "variables": { "company_name": "Acme Corp", "support_level": "premium", }, }, ) # Dynamic template reference async def dynamic_prompt( context: RunContextWrapper[UserContext], agent: Agent, ) -> dict: user = context.context return { "id": "pmpt_abc123", "version": "2", "variables": { "company_name": "support_level": user.plan, "language": user.language, }, } agent_dynamic = Agent( name="dynamic-support", prompt=dynamic_prompt, ) ``` 🏗 Building it into production ・Manage prompts on the platform for updates and rollbacks without code deployment ・Use version pinning for stable behavior while gradually rolling out new versions ・Inject user-attribute-based variables with dynamic templates ・Share and reuse prompts across teams for quality standardization 💡 Use cases 📝 Prompt version management and staged rollouts 🏢 Cross-organization prompt sharing and standardization 🔄 Prompt updates without code deployment 👤 Dynamic variable injection based on user attributes ⚠️ Watch out `prompt` and `instructions` are mutually exclusive; specifying both causes an error. If the referenced prompt doesn't exist on the platform, you'll also get an error. Verify prompt IDs and versions before deployment, and watch for variable name typos. ✨ With Prompt Templates, move prompt management from "inside the code" to "the platform dashboard." #OpenAIAgentSDK# #AIAgent#
Show more
# Learning Palantir Foundry 🚀 Answer "where did this dashboard number come from?" in an instant. Data Lineage is an exploration tool that visualizes the entire flow of your data. 📌 Title and Feature URL Title: Data Lineage URL: 📝 Overview Data Lineage is an interactive visualization tool that comprehensively shows how data flows through the Foundry platform. It helps you understand data movement, dependencies, and transformations across your entire data ecosystem. Because you can trace the lineage from sources through pipelines, the Ontology, and apps as a graph, it sharply reduces the cost of incident response and audit explanations. 🔧 How It Works It represents data dependencies through a graph-based visualization. - Find datasets using project names, table identifiers, or row labels, and browse data directly from Foundry Projects - Expand or collapse ancestor (upstream) and descendant (downstream) relationships for any dataset - View multiple table attributes at once, down to schema details, build timestamps, and source code - Apply custom color schemes to highlight pipeline characteristics such as stale datasets - Create shareable pipeline snapshots to communicate within the team 🛠 Practical Usage - Trace upstream from a dashboard or output dataset to pinpoint the source of a number - When an upstream schema changes, trace downstream to map the blast radius - Color-code stale datasets to discover neglected pipelines - Drill down from a high-level overview into granular technical details like transformation code and execution history - Share pipeline snapshots to document data workflows across functions 🎯 Use Cases - Instantly answering "what is the origin of this dashboard's number" - Identifying the impact scope of upstream schema changes in advance to prevent incidents - Presenting data lineage during audits to cut explanation costs - Finding stale or unused datasets to tidy up pipelines ⚠️ Caveats - This overview page does not explicitly discuss performance or graph-complexity constraints with extremely large pipelines - Lineage covers data flow within the Foundry platform; processing outside the platform is out of visualization scope - The accuracy of lineage depends on transforms and pipelines being properly configured within Foundry #PalantirFoundry# #DataLineage#
Show more
Harness Engineering Practices P7. Negative Verification — Regression and Blast Radius Gates 🎯 Point Agents optimize for "my change works" and underweight "I haven't broken anything else." Positive verification alone won't catch escaped defects. 📝 Overview Add blast radius checks to completion gates — beyond running the full existing test suite, verify "who imports the symbols I touched." Negative verification confirms not just that your code works, but that nothing else is broken. 🔍 Explanation Agents naturally focus on "tests related to my change pass." But change impact doesn't stop at the changed code. Altering a function signature breaks callers; changing shared module behavior affects all dependents. Negative verification is the explicit mechanism for verifying "nothing was broken." Identify import sites of changed symbols, run their tests too. Embedding impact visualization and test execution into the completion gate structurally prevents escaped defects. 🛠 How to Practice - Integrate tooling into completion gates that auto-identifies import sites of changed symbols via static analysis (import analysis, call graphs) - Automatically add identified dependent tests to the execution set alongside the existing test suite - Visualize change blast radius (impacted file count, module count) alongside the diff and present it to reviewers - Combine coverage data with static analysis to identify and flag under-tested impact areas 💼 Use Cases - Issue-to-PR agents: auto-run all dependent tests when shared utilities are modified - Migration agents: verify the full impact zone of API signature changes - Legacy code modernization: cover change ripple effects with characterization tests ⚠ Pitfalls Exhaustive blast radius checking can spiral into running the entire monorepo test suite, which is impractical. Combining static analysis (import analysis, call graphs) with dynamic analysis (coverage data) is most effective. Also, negative verification existing doesn't mean you can neglect positive verification — both are necessary. #HarnessEngineering# #QualityAssurance#
Show more
# Practical and Useful Patterns for OpenAI Agent SDK 🌍 Want to filter what goes into the model or gracefully handle errors without crashing? Input filters and error handlers give you fine-grained control over agent behavior at the edges. 📌 Title: Running agents – Hooks and customization / Error handlers 🔗 URL: 🧩 Overview `call_model_input_filter` is a hook that transforms model input just before it's sent — perfect for trimming history, masking secrets, or injecting dynamic system instructions. `error_handlers` lets you catch specific errors (tool failures, model refusals, max turns) and return app-specific fallback output instead of raising exceptions. Together, they enable production-grade resilient agents. 🛠 Usage Import `Agent`, `Runner`, and `ErrorHandlers` from `agents`. Define `trim_history(input_data)` to keep only the last 10 messages via `input_data.messages = input_data.messages[-10:]`, and `mask_secrets(input_data)` to replace secrets with `msg.content.replace(os.environ.get("API_KEY", ""), "***")`. Define `handle_refusal(ctx, error)` to return a domain-specific fallback on model refusal. Configure the agent with `Agent(name="chef", instructions="You are a recipe assistant.", call_model_input_filter=trim_history, error_handlers=ErrorHandlers(model_refusal=handle_refusal, max_turns=lambda ctx, err: FallbackOutput(message="Processing did not complete. Try shorter input.", include_in_history=False)))`. 🏗 Practical Patterns **History Trimming for Cost Control** Use `call_model_input_filter` to keep only the last N messages, reducing token consumption in long conversations. A practical pattern: always preserve the system prompt at the top while pruning older user messages. **Secret Masking** When tool outputs contain API keys or tokens, mask them before they reach the model via the input filter. This reduces the risk of the model memorizing or echoing sensitive information. **Dynamic System Instruction Injection** Inside the filter, inject context-aware system instructions based on user permissions or state. For example: "This customer is on the Premium plan" — letting the model tailor its responses dynamically. **Graceful max_turns Fallback** When a looping agent hits the turn limit, return a user-friendly message instead of an exception. Setting `include_in_history=False` keeps the fallback out of future turns, so retries start clean. **App-Specific Model Refusal Handling** Instead of catching `ModelRefusalError` and returning a generic error, return a structured fallback matching your domain model. A recipe app returns an empty Recipe with `refusal_reason`; a chat app suggests alternative topics. 💡 Use Cases 🔒 Prevent API keys and tokens from reaching the model 📏 Auto-trim long chat history to optimize token costs 🔄 Guide users to next actions when max_turns is reached 🛡 Return structured domain-specific fallbacks on model refusal ⚠️ Caveats - Over-pruning messages in `call_model_input_filter` causes the model to lose context and degrade response quality. Always preserve critical system prompts. - Ensure fallback outputs from `error_handlers` match the agent's `output_type`. Type mismatches cause runtime errors. - Fallback outputs with `include_in_history=False` won't be available in subsequent turns. Use this only for display-only information. - Exceptions thrown inside filters or handlers will halt the entire agent. Write defensive logic within these hooks. ✨ Combine input filters and error handlers to build agents that handle edge cases gracefully in production! #OpenAIAgentSDK# #AIAgent#
Show more
# Codex Features and Practical Usage 🧩 Tired of re-explaining the same workflow to Codex every time? Agent Skills let you package a reusable playbook once, and Codex loads it only when it is actually needed. 🏷️ Title: Agent Skills (SKILL.md) 🔗 URL: 📘 Overview Agent Skills package routine workflows into a single `SKILL.md` file you can reuse. Only a skill's name and description sit in Codex's context at all times; the full body loads when Codex decides to invoke it. You scope skills by where you place them: repository-wide, personal, or machine-level. ⚙️ How It Works ・A skill is a folder with `SKILL.md` (required) plus optional `scripts/` (executable code), `references/` (docs), `assets/` (templates), and `agents/openai.yaml` (UI config). ・`SKILL.md` opens with frontmatter containing `name` and `description`. A good description states clearly when the skill triggers and what its boundaries are. ・Codex scans several locations in priority order: the repo's `.agents/skills`, `$REPO_ROOT/.agents/skills`, your personal `$HOME/.agents/skills`, the admin path `/etc/codex/skills`, and OpenAI's bundled built-in skills. ・Progressive disclosure keeps only names, descriptions, and paths in the initial context (capped around 8,000 characters). The full body loads on invocation, so many installed skills won't bloat the prompt. 🛠️ Practical Usage ・The easiest way to author one is the built-in `$skill-creator`. It walks you through what the skill does, when it triggers, and whether to bundle scripts (instruction-only is the default). ・Invoke explicitly with `/skills` in the CLI/IDE, or mention a skill by name like `$skill-name`. Codex also selects skills implicitly when your task matches the description. ・To forbid implicit selection for a skill, set `policy.allow_implicit_invocation` to `false` in `agents/openai.yaml`. ・To disable a skill without deleting it, add a `[[skills.config]]` entry with its `path` and `enabled = false` in `~/.codex/config.toml`. 💡 Use Cases Encode error-prone, brittle routines such as release procedures, how to run the E2E suite, or the correct way to use an internal library. Anyone on the team then gets consistent results from Codex. Put shared workflows under the repo and personal habits under `$HOME/.agents/skills` for a clean split. ⚠️ Caveats ・Duplicate skill names across locations are not merged; both appear in the selector, so keep names unique. ・A vague description breaks implicit matching. Front-load key use cases and be concrete. ・With many skills installed, descriptions may be shortened to save context. If changes don't show up, restart Codex. #OpenAICodex# #AgentSkills#
Show more
# Practices for Embedding AI Agents in Software # Tool Gateway / MCP Broker 🎯 The Hook Your AI agent calls multiple tools directly? That's a distributed security nightmare waiting to happen. A single gateway layer turns chaos into a controlled chokepoint. 🔥 The Problem When agents call external tools and MCP servers directly, authorization, rate limiting, and logging scatter across every integration. Prompt injection can sneak malicious arguments past individual tools, and audit trails become impossible to reconstruct when logs are spread across a dozen services. 💡 The Pattern Route all tool calls through a single gateway that enforces authorization, input sanitization, rate limiting, and audit logging in one place. Use dynamic scoping to expose only the tools relevant to the current task and user permissions, keeping the LLM's selection space narrow. Apply asymmetric policies: write operations get fine-grained per-operation authorization and HITL approval, while read operations use lighter category-level checks. Adding or removing tools becomes a configuration change, not a code deployment. ✅ When to Use Use when: - The agent calls multiple tools, at least one with side effects - User input or external data flows into tool arguments (low input trust) - You need an audit trail of who called what, with which arguments, and under whose authority Don't use when: - There's only one read-only tool and gateway overhead isn't justified - All tools are trusted internal services in an experimental environment where prototype speed matters more ⚠️ Pitfalls - The gateway itself becomes a single point of failure. Design health checks and a degraded mode (e.g., read-only fallback) - Never enforce authorization or sanitization via prompts. "Don't use this tool" instructions are trivially bypassed by injection - Session-level rate limits alone won't stop distributed attacks. Add a global rate limit layer on top 🔧 Implementation Approach - Define gateway policies declaratively (e.g., YAML), specifying type (read/write), authorization granularity, rate limits, sanitization rules, and log levels per tool - Dynamically scope tools exposed to the LLM based on task type, user permissions, and conversation phase, excluding irrelevant tools from the selection space - Design health checks and a degraded mode (read-only fallback) so the system survives gateway failures without total shutdown - Normalize schemas across MCP servers at the gateway layer, presenting a consistent interface to agents regardless of backend differences - Route high-risk code execution to sandboxed environments and use short-lived permission leases for long-running sessions #AIAgents# #SoftwareArchitecture#
Show more