Simple Q&A
Best for: Direct questions, explanations, definitions
Pattern: Configure → Prompt → GetResponse
Example: “What is Docker?” → Get explanation text
Execute the agent and return the raw LLM response as a string. This is a execution method that triggers agent execution and returns only the response content - not the agent instance for chaining.
getResponse(): Promise<string>
This method takes no parameters.
Returns a Promise<string>
containing the raw LLM response.
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "QuestionAgent"}) .useLLM("ollama", "gemma3:4b") .prompt("What is the capital of France?");
const response = await agent.getResponse();console.log(response); // "Paris is the capital of France."
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "CodeGenerator"}) .systemPrompt("You are a TypeScript expert") .useLLM("google", "gemini-1.5-flash") .prompt("Create a function to validate email addresses");
const codeResponse = await agent.getResponse();console.log("Generated code:");console.log(codeResponse);
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "FileAnalyzer", tools: ["fs_find_files"]}) .useLLM("ollama", "qwen3-coder-tool", { appendToolResults: true, maxToolRounds: 2 }) .systemPrompt("You are a file system analyst") .prompt("Find all .ts files in the src directory and count them");
const analysisResponse = await agent.getResponse();console.log("File analysis:");console.log(analysisResponse);
import { AgentForceAgent, type AgentConfig } from '@agentforce/adk';
const config: AgentConfig = { name: "DebugExclusionsTest", tools: ["fs_find_files"]};
const DebugExclusionsTest = new AgentForceAgent(config) .useLLM("ollama", "qwen3-coder-tool", { appendToolResults: true, maxToolRounds: 2 }) .systemPrompt("You are a debugging assistant. Show me the exclusions and found files data exactly as provided by the tool.") .prompt("Search for all .md files and show me the raw exclusions list that was applied");
const response = await DebugExclusionsTest.getResponse();console.log("Debug Output:");console.log(response);
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "ContentSummarizer", tools: ["web_fetch"]}) .systemPrompt("You are an expert at summarizing web content concisely") .useLLM("openrouter", "mistralai/mistral-small") .prompt("Fetch and summarize the main points from https://example.com/article");
const summary = await agent.getResponse();console.log("Article Summary:");console.log(summary);
import { AgentForceAgent } from '@agentforce/adk';
const agent = new AgentForceAgent({ name: "DataAnalyst", tools: ["fs_read_file"]}) .systemPrompt("You are a data analyst. Provide clear, actionable insights.") .useLLM("google", "gemini-1.5-pro") .prompt("Read 'data/sales-q4.csv' and identify the top 3 trends with specific numbers");
const insights = await agent.getResponse();console.log("Data Insights:");console.log(insights);
// Get response and process itconst agent = new AgentForceAgent({ name: "ProcessingAgent" }) .systemPrompt("Return your response as valid JSON") .prompt("List 3 programming languages with their main use cases");
const response = await agent.getResponse();
try { // Try to parse as JSON const data = JSON.parse(response); console.log("Structured data:", data);} catch (error) { // Handle as plain text console.log("Plain text response:", response);}
class ResponseProcessor { static async getAndProcess(agent: AgentForceAgent) { const response = await agent.getResponse();
return { raw: response, wordCount: response.split(/\s+/).length, lines: response.split('\n').length, isEmpty: response.trim().length === 0, containsCode: /```/.test(response), timestamp: new Date().toISOString() }; }}
// Usageconst agent = new AgentForceAgent({ name: "ProcessedAgent" }) .prompt("Write a short poem about coding");
const result = await ResponseProcessor.getAndProcess(agent);console.log("Response metadata:", result);
Simple Q&A
Best for: Direct questions, explanations, definitions
Pattern: Configure → Prompt → GetResponse
Example: “What is Docker?” → Get explanation text
Content Generation
Best for: Blog posts, documentation, creative writing
Pattern: System prompt for style → Content request → GetResponse
Example: Generate marketing copy or technical documentation
Tool Output Analysis
Best for: Debugging tool behavior, analyzing tool results
Pattern: Tools enabled → Analysis prompt → GetResponse
Example: File system analysis with fs_find_files tool
Raw Response Debugging
Best for: Debugging agent behavior, testing prompts
Pattern: Debug system prompt → Test prompt → GetResponse
Example: Testing how the agent responds to specific inputs
// Clear, specific promptsconst response = await agent .systemPrompt("You are a technical writer") .prompt("Explain REST APIs in 200 words for beginners") .getResponse();
// Handle responses appropriatelyconst result = await agent.getResponse();if (result.startsWith("Error:")) { console.error("Agent encountered an error:", result);} else { console.log("Success:", result);}
// Process response content when neededconst jsonResponse = await agent.getResponse();try { const data = JSON.parse(jsonResponse); // Work with structured data} catch { // Handle as plain text}
// ❌ Trying to chain after getResponse()const result = await agent .prompt("Hello") .getResponse() .prompt("Follow up"); // Error: getResponse() is terminal
// ❌ Not handling async properlyconst response = agent.getResponse(); // Missing awaitconsole.log(response); // Logs Promise object
// ❌ Not handling potential errorsconst response = await agent.getResponse(); // Could throw or return error message// Should check if response indicates an error
// Error handling is built-inconst agent = new AgentForceAgent({ name: "ErrorProneAgent", tools: ["nonexistent_tool"] // This will cause an error}) .prompt("Use the nonexistent tool");
try { const response = await agent.getResponse(); // If execution fails, the method will return the error message from chat history console.log("Response (may contain error):", response);} catch (error) { // Only throws if no error message is found in chat history console.error("Execution failed:", error.message);}
.output()
- Execute and return structured output with format control.run()
- Execute multi-step task workflows.prompt()
- Set the main user prompt.systemPrompt()
- Configure agent behavior