diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..930cce6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.codegraph/ diff --git a/agent.py b/agent.py index bd596ec..4da186f 100644 --- a/agent.py +++ b/agent.py @@ -290,6 +290,7 @@ class BlogOpenapiAgent(A2AAgent): "Call tools to get real results. Do not invent API responses.", "For write, update, or delete operations, explain the intended action before calling the tool.", "If an operation reports missing consumer setup, tell the user which setup field is required.", + "If an operation returns 404, 405, 410, or a schema/validation error that suggests the live API no longer matches these tools, tell the user this generated agent may need to be refreshed from the latest OpenAPI spec and ask whether they want to refresh it.", "", "Available operations:", ] @@ -346,12 +347,18 @@ class BlogOpenapiAgent(A2AAgent): except ValueError: payload = response.text if response.status_code >= 400: - return { + out = { "ok": False, "status_code": response.status_code, "operation_id": operation_id, "error": payload, } + if response.status_code in {404, 405, 410, 422}: + out["stale_openapi_hint"] = ( + "This generated OpenAPI agent may be stale. Ask the user " + "whether they want to refresh it from the latest OpenAPI spec." + ) + return out return { "ok": True, "status_code": response.status_code,