AI research agent with OpenAI function calling for n8n. Port of sgr-agent-core Python project.
Copyright (C) 2025 MiXaiLL76 (mike.milos@yandex.ru)
n8n is a fair-code licensed workflow automation platform.
Follow the installation guide in the n8n community nodes documentation.
- Add SGR Agent node to your workflow
- Connect AI Language Model (OpenAI, Anthropic, etc.)
- Connect AI Tools (optional): search, MCP, LangChain tools
- Connect Memory (optional): for conversation history
Chat Trigger → SGR Agent → Output
↓ ↓ ↓ ↓
[Model][Tools][Memory]
Import SGR_Example.json to get started.
Agent uses 6 system tools for research tasks:
reasoning_tool- analyze task and plan next stepsfinal_answer_tool- complete task executioncreate_report_tool- generate detailed reports with citationsclarification_tool- ask clarifying questionsgenerate_plan_tool- create research plansadapt_plan_tool- adjust plans based on findings
All tools can be enabled/disabled in node settings.
Connect any n8n AI Tool:
- SGR Tavily Search - web search (included)
- SGR Custom Final Answer Tool - customizable final answer schema (included)
- MCP Client Tool - Model Context Protocol integrations
- LangChain Tools - calculators, code interpreters, etc.
- Supports the
/toolscommand to display all connected tools
Agent automatically highlights connected tools when they execute.
Allows you to customize the JSON schema for the final answer tool:
- Define your own schema structure using JSON Schema format
- Default schema imported from
nodes/SGR/tools/finalAnswer.ts - Automatically disables built-in Final Answer and Clarification tools when connected
- Built-in schema validation ensures proper format
- Supports both full JSON return or field extraction
- Perfect for custom report formats with specific fields like citations, confidence scores, metadata, etc.
Connect n8n Memory node for conversation history:
- Remembers previous interactions within session
- Automatically clears when
sessionIdchanges - Supports
/clearand/newcommands - Only stores user questions and final answers (not internal reasoning)
- Clarification Support: preserves conversation context when agent requests clarifications
When agent needs clarification, it uses the clarification_tool to ask questions:
-
Agent Requests Clarification
- Agent analyzes the task and identifies ambiguous terms
- Calls
clarification_toolwith 3 specific questions - Conversation history (including questions) is saved to Memory
- Execution pauses with state
WAITING_FOR_CLARIFICATION
-
User Provides Answers
- Send answers via
clarificationAnswersfield in input - Agent loads conversation history from Memory
- Continues research with full context
- Send answers via
Configure resource constraints:
- Max Iterations (default: 10) - reasoning cycles before stopping
- Max Searches (default: 4) - web search limit
- Max Clarifications (default: 3) - clarification request limit
Override default prompts:
- System Prompt - agent behavior instructions
- Initial User Request Template - format task presentation
- Clarification Response Template - format clarification responses
- n8n community nodes documentation
- SGR Deep Research (Original Python Project)
- n8n AI Agents Documentation
This project is licensed under AGPL-3.0 - see the LICENSE file for details.
AGPL-3.0 requires you to open-source your modifications and provide source code to users if you run this software as a network service.
For commercial use where you want to:
- Keep your modifications private
- Integrate into proprietary software
- Provide as a managed service without open-sourcing
Contact for a commercial license: mike.milos@yandex.ru
This software is free for:
- ✅ Personal use
- ✅ Educational purposes
- ✅ Research projects
- ✅ Open-source projects (compliant with AGPL-3.0)
If you modify and deploy this software as a network service, you must provide source code to your users under AGPL-3.0 terms.
