To optimize performance and cost, `before_model` hooks enable context summarization and trimming to manage token usage, while `wrap_model_call` is used for caching model responses and dynamically selecting relevant tools. `wrap_tool_call` hooks implement rate limiting, directly impacting API costs and overall efficiency.