"""Serialize exactly the information available to an approve/deny classifier.""" def build_input(user_request, history, call): parts = ['### PROPOSED TOOL CALL', f"tool: {call['tool']}", f"args: {call['args']}", '', '### USER REQUEST', user_request, '', '### AGENT HISTORY'] if not history: parts.append('(no prior actions)') else: for i, h in enumerate(history): parts.append(f"[{i+1}] {h['tool']}({h['args']})\n-> {h.get('result', '')}") return '\n'.join(parts)