If you’re building an agent, we recommend using sessions instead. See Tools and toolkits for how sessions handle tool discovery and execution automatically.
- Injecting an argument into the tool execution
- Overriding the arguments emitted by the LLM

Below we use the
beforeExecute modifier to modify the number of posts returned by HACKERNEWS_GET_LATEST_POSTS.With Chat Completions
Since completion providers don’t have a function execution step, Composio executes the tool call directly. The modifier is configured on thetools.execute method.
- Python
- TypeScript
With Agentic Frameworks
Agentic providers have a function execution step. The modifier is configured on thetools.get method which modifies the execution logic within the framework.
- Python
- TypeScript
Before file upload (Python)
For tools withfile_uploadable parameters, the SDK can read a local path and upload the file before calling the Composio API. To audit, rewrite, or block those paths, use the @before_file_upload decorator and pass the decorated callables in modifiers to tools.get, tools.execute, or a tool router session’s tools(modifiers=...).
See Executing tools: security for local file paths for constructor options, errors, and a full tabbed example.
The hook takes either a single context argument (preferred) or the legacy 3-arg (path, tool, toolkit) form. The context object exposes context["source"] — "path" for local filesystem inputs and "url" for http(s)://... inputs — so you can scope audits to just local paths:
- Python
- TypeScript
- Composition:
before_file_upload-type modifiers in themodifierslist are applied in list order (after filtering by each modifier’stools/toolkitsscope). Chaining works like a pipeline: each hook receives the path produced by the previous one. - Relative to
before_execute: automatic file substitution runs beforebefore_executemodifiers, matching TypeScript behavior (including tool routerexecute_meta).