AI agents and MCP in Java
19 questions in 5 subtopics.
Agents and tool loops
What is a tool-calling loop in an LLM agent? Describe the steps between the user's message and the final answer when the model decides to call a Java method such asgetOrderStatus(orderId).Using Spring AI, expose a method that looks up an order's status as a tool and let a ChatClient call it. What do you put in the tool description, and how do you avoid letting the model read other customers' orders?An agent in production sometimes makes 40 tool calls for one request, costs spike, and some answers mention refunds that were never issued. How do you investigate and fix it?Design the architecture for an agent that helps support staff resolve billing issues by reading account data, explaining invoices and proposing credits, across five backend services.Leadership wants 'agents everywhere' within a year. As the senior technical leader, how do you decide where agents are worth it and where simple automation or a plain LLM call is better?Model Context Protocol servers and clients
What is the Model Context Protocol (MCP)? Explain servers, clients, tools, resources and prompts, and the transports a Java MCP server can use.Build an MCP server in a Spring Boot application that exposes asearchTickets tool over HTTP for internal AI assistants. Outline the dependencies, the tool definition and how you secure it.A developer connects a third-party MCP server to an internal assistant that also has a tool which sends emails. A crafted document read through the third-party server makes the assistant email internal data outside. Explain the attack and the defences.Your company wants to expose 30 internal systems to AI assistants through MCP. Design the platform: hosting, discovery, identity, and change management for tool schemas.MCP appeared recently and adoption moved fast. How do you decide how much to standardise on it for the next five years, given that protocols in this area may change?Multi-agent systems
What are common patterns for combining several LLM agents (sequential pipeline, router, orchestrator with workers, evaluator loop), and how would you implement a router in Java?A team proposes a multi-agent system with a planner agent, a research agent, a coding agent and a reviewer agent for internal report generation. When is this better than one agent with several tools, and what problems should you expect?In a multi-agent pipeline, the reviewer agent approves almost everything the writer agent produces, and errors reach users. How do you make review effective?Chatbots in Java
Build a customer-facing chatbot endpoint in Spring Boot with Spring AI that remembers the last messages of a conversation. How do you store memory and keep the prompt within token limits?Design a Java chatbot that answers questions about your product documentation with citations, using retrieval-augmented generation. Describe ingestion, retrieval, prompting and evaluation.Your company's public chatbot gave a customer wrong refund information, and the customer took legal action. What changes would you make to the chatbot programme?Guardrails and human approval
What are input and output guardrails for an LLM application, and give three concrete checks you would implement in a Java service before showing a model's answer to a user.An agent can issue refunds up to 500 dollars. Design the human approval flow so the agent proposes refunds, a person approves, and nothing is paid twice or without approval.How would you set company-wide policy on which actions AI agents may take autonomously, which need human approval and which are forbidden?No question matches these choices.