Repository navigation
Approval, invocation caps and idempotent writes in Agent Framework (free MIT patterns) #10356
stackyardweekstart
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Disclosure: this is ours, from Stackyard. It's a free, MIT-licensed set of 10 small habits for agents that touch files, money or APIs, each a short guide plus a snippet to adapt: https://github.com/stackyardweekstart/weekstart-starter-pack
Where four of them sit in Microsoft Agent Framework (Python):
Confirm before a write: mark irreversible tools with
@tool(approval_mode="always_require"). The run pauses; inspectresult.user_input_requests, then resume the sameAgentSessionwithto_function_approval_response. No answer counts as no.Per-run ceiling: set
client.function_invocation_configuration["max_iterations"]to cap model round-trips (default 40). That does not cap parallel tool calls in one turn, so also setmax_function_callsandmax_duration_secondson the same config, andmax_invocationson an expensive tool.One key per write: mint the idempotency key inside the tool (or in
FunctionMiddleware.process, from the tool name and arguments) and reuse it if the model retries the same call after an error.Read vs did: log function calls and their results apart, under one run id. Tool returns and messages from other agents in a workflow are data to check, not instructions.
Free weekly brief on agent tool and API changes: https://stackyard.fyi
All reactions