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

Search results for BetweenSteps
BetweenSteps community
One keyword maps to one global community path.
Create community
People
Not Found
Tweets including BetweenSteps
A useful but little-known Claude API feature 🔒 Tool arguments occasionally not matching the schema? Fix it structurally, not with more validation code. Claude's Strict Tool Use guarantees that tool calls always exactly match the defined schema when you add strict: true. No more missing required fields, type mismatches, or unexpected extras. 📌 Title: Strict Tool Use 🔗 URL: 🧩 Overview When models call tools, arguments occasionally deviate from the schema: missing required fields, wrong types, extra properties. Enabling Strict Tool Use constrains the model's output to strictly conform to the tool's JSON schema. Invalid arguments become structurally impossible, letting you dramatically simplify your validation code. 🛠 How to use it Add strict: true at the top level of your tool definition. Your schema does have to stay within the supported JSON Schema subset, and objects must set `additionalProperties: false` (constraints like `minimum` and `maxLength` aren't supported and return a 400). Once enabled, the model generates only schema-compliant arguments. You can drop or reduce type and required field validation code, simplifying error handling on the tool execution side. 🏗 Building it into production ・Agent tool infrastructure: add strict: true to all tools and eliminate runtime errors from bad arguments. Debugging time drops significantly. ・External API integrations: when tool arguments are used directly as external API request bodies, schema compliance guarantees safe passthrough. ・Multi-step pipelines: ensure type-safe data flow when using tools for data handoffs between steps. ・Validation cost reduction: remove or simplify argument validation logic, lowering code maintenance burden. 💡 Use cases 🤖 Tool argument quality assurance for agents 🔌 Safe argument passthrough to external APIs 🔗 Type-safe data handoffs between pipeline steps 🧹 Elimination of validation boilerplate ⚠️ Watch out Strict mode constrains output with a grammar compiled from your schema, so the first request using a given schema pays extra compilation latency (compiled grammars are cached for 24 hours after last use). There are explicit complexity limits: 20 strict tools, 24 optional parameters, and 16 union-typed parameters in total per request, and exceeding them returns a 400. It works best with straightforward schemas. ✨ Stop writing "hope the arguments are valid" code. One line, strict: true, and your tool calls become reliably correct. #Claude# #LLM#
Show more
# Practices for Embedding AI Agents in Software # Short DB Transaction, Long Agent Session 🎯 The Hook Holding a database transaction open while the LLM thinks for 30 seconds? Your connection pool will starve and the entire system grinds to a halt. Separate the long session from the short transaction. 🔥 The Problem Traditional web apps finish request processing in milliseconds, so request-scoped transactions work fine. AI agents are different -- LLM calls take seconds to minutes. Keeping a transaction open during inference causes connection pool exhaustion, deadlocks, lock contention, and transaction timeouts. With P99 latency often several times P50, designs that work "on average" fail at the tail. 💡 The Pattern Never hold a transaction or database connection during LLM inference. Read data in a short transaction, commit and release the connection, call the LLM, then write results in a new short transaction. Intermediate state between steps is persisted to an external state store (Redis, DynamoDB, or a session table). Use optimistic locking (version columns) to handle data races during inference -- never hold pessimistic locks across LLM calls. This reduces required connection pool size to roughly 10-20% of concurrent sessions. ✅ When to Use Use when: - The agent reads from and writes to a database around LLM calls - LLM call latency exceeds roughly 1 second (most LLM calls qualify) - Concurrent session count may reach half the connection pool size Don't use when: - Traditional CRUD processing with no LLM involvement - Operations that must complete atomically in a single transaction (e.g., bank transfers) ⚠️ Pitfalls - Between read and write, another process may update the same row. Always use optimistic locking (version column or updated_at check) - Size your connection pool for concurrent transaction steps, not concurrent sessions. This pattern dramatically reduces the required pool size - For sessions involving irreversible operations, choose a state store with disk persistence over purely in-memory stores 🔧 Implementation Approach - Follow the sequence: short read transaction, commit, release connection, LLM call, re-acquire connection, short write transaction -- never hold transactions or connections during inference - Include optimistic locking (version column or updated_at) in write transactions to handle data races during LLM inference via retry - Persist intermediate state between steps in an external state store (Redis, DynamoDB, or RDB session table) to enable recovery after crashes - Size connection pools for concurrent transaction steps, not concurrent sessions -- typically 10-20% of concurrent session count suffices - For sessions involving irreversible operations, select a state store with disk persistence to meet durability requirements #AIAgents# #SoftwareArchitecture#
Show more