AI agent tasks, including multi-step reasoning, document analysis, and model chains, can take anywhere from 30 seconds to several minutes. HTTP gateways on every cloud platform, including GMI, close connections that stay open too long and return a 504 Gateway Timeout to the caller.The fix is to decouple accepting the request from returning the result.A 504 from a slow task and a connection failure are two different problems. If your endpoint is unreachable, first check that ingress is enabled and networking is configured for your deployment. The async pattern below only helps when the request reaches your agent, but the work takes too long to finish inside the gateway window.
GMI containers are stateless. If a container restarts, any in-memory job state is lost. For production, write the job state to an external store such as Redis or a database, and inject the connection credentials as Secrets in Step 3 of Register an agent.