From c7fdc6a9129e94756c4a99c2765352496efcfc9a Mon Sep 17 00:00:00 2001 From: Till Immer Date: Sun, 5 Jul 2026 13:00:00 +0000 Subject: [PATCH] agent.py aktualisiert --- agent.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/agent.py b/agent.py index e9bf434..fb88c09 100644 --- a/agent.py +++ b/agent.py @@ -34,20 +34,27 @@ class Agent: async def load_tools(self): try: res = await self.mcp.list_tools() - - self.tools = [ - { + + self.tools = [] + for t in res.tools: + schema = t.inputSchema + + # Bedrock-kompatibles Format erzwingen + if isinstance(schema, dict) and "json" not in schema: + bedrock_schema = {"json": schema} + else: + bedrock_schema = schema + + self.tools.append({ "toolSpec": { "name": t.name, "description": t.description, - "inputSchema": t.inputSchema + "inputSchema": bedrock_schema } - } - for t in res.tools - ] - - self.logger.info(f"{len(self.tools)} Tools erfolgreich geladen") - + }) + + self.logger.info(f"{len(self.tools)} Tools erfolgreich für Bedrock angepasst und geladen") + except Exception as e: self.logger.error(f"Tool Load Error: {e}") self.tools = []