Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 9 additions & 43 deletions agent.py
Original file line number Diff line number Diff line change
@@ -1,66 +1,32 @@
from langchain_ollama import ChatOllama
from langchain.agents import create_agent
from langchain_core.runnables import RunnableConfig
from tools.wiki import wiki_search
from tools.math import smart_math
from tools.getNews import asknews_search
from tools.arxiv_tool import arxiv_search
from tools.duckduckgo import duck_duck_go_search, duck_duck_go_search_results
from tools.getDate import get_current_date
from tools.save_md import save_md_locally
from tools.summarize_text import summarize_text
from tools.serpSearch import serp_search
from tools.save_md_plus import save_md_plus
from tools.SearxNG import searx_search
from tools.crossref import crossref_search
from tools.unpaywall import unpaywall_lookup
from tools.europe_pmc import europe_pmc_search
from tools.openlibrary import openlibrary_search
from retriever import add_to_db,query_db
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT_GENERIC, KURAMA_RESEARCH_PROMPT_DEEPRESEARCH
from tools.tools_wrapper import tools
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT_GENERIC, KURAMA_RESEARCH_PROMPT_DEEPRESEARCH,KURAMA_RESEARCH_PROMPT

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in the import statement. Python style guidelines (PEP 8) recommend adding a space after commas in import statements for better readability.

Suggested change
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT_GENERIC, KURAMA_RESEARCH_PROMPT_DEEPRESEARCH,KURAMA_RESEARCH_PROMPT
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT_GENERIC, KURAMA_RESEARCH_PROMPT_DEEPRESEARCH, KURAMA_RESEARCH_PROMPT

Copilot uses AI. Check for mistakes.

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'KURAMA_RESEARCH_PROMPT_GENERIC' is not used.
Import of 'KURAMA_RESEARCH_PROMPT_DEEPRESEARCH' is not used.

Suggested change
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT_GENERIC, KURAMA_RESEARCH_PROMPT_DEEPRESEARCH,KURAMA_RESEARCH_PROMPT
from prompts.research_prompt import KURAMA_RESEARCH_PROMPT

Copilot uses AI. Check for mistakes.
from dotenv import load_dotenv
import os
from utils.spinner import Spinner
from utils.markdown_render import render_markdown
from langgraph.errors import GraphRecursionError
from pyfiglet import Figlet

def main():

load_dotenv()
f = Figlet(font='standard')
print(f.renderText('Kurama v 1.3'))
x = input("Ask Kurama 🦊\n")
load_dotenv()

llm = ChatOllama(model="gpt-oss:120b-cloud", temperature=0.7)
recursion_limit = 100
llm = ChatOllama(model="gpt-oss:120b-cloud", temperature=0.7,verbose=True)

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in the function call. Python style guidelines (PEP 8) recommend adding a space after commas in function arguments for better readability.

Suggested change
llm = ChatOllama(model="gpt-oss:120b-cloud", temperature=0.7,verbose=True)
llm = ChatOllama(model="gpt-oss:120b-cloud", temperature=0.7, verbose=True)

Copilot uses AI. Check for mistakes.
recursion_limit = 50
config = RunnableConfig(tags=["debug", "local"], recursion_limit=recursion_limit)
agent = create_agent(
model=llm,
tools=[
wiki_search,
smart_math,
duck_duck_go_search,
duck_duck_go_search_results,
searx_search,
add_to_db,
query_db,
asknews_search,
serp_search,
arxiv_search,
crossref_search,
unpaywall_lookup,
europe_pmc_search,
openlibrary_search,
get_current_date,
save_md_locally,
save_md_plus,
summarize_text,
],
system_prompt=KURAMA_RESEARCH_PROMPT_GENERIC
tools=tools,
system_prompt=KURAMA_RESEARCH_PROMPT
)

result = None
MAX_RECURSION_LIMIT = 1000
MAX_RECURSION_LIMIT = 100
while True:
s = Spinner("Reasoning | Choosing tools | Gathering info")
s.start()
Expand Down
67 changes: 67 additions & 0 deletions prompts/research_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,71 @@

You are Kurama Research Agent in **Deep Mode**.
Your purpose is to produce **multi-page, publication-grade Markdown research reports**, saving each section progressively while maintaining local, persistent knowledge across sessions.
"""


Tools = """
# Role
You are **Kurama Research Agent v1.3**, an autonomous research assistant built by Vedas Dixit.

Below are strict rules for you to follow:
Do's:
-> Internal reason before taking action
-> never process sensitive request that makes you search any negative things and abuse tool calling in terms of. "*add thinhs herr"

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains multiple issues: incomplete sentence structure, unclear meaning, and a spelling error. The text "never process sensitive request that makes you search any negative things and abuse tool calling in terms of. "*add thinhs herr"" is grammatically incorrect and contains the spelling error "thinhs" instead of "things". Additionally, the line ends with an incomplete thought and unexplained placeholder text.

Suggested change
-> never process sensitive request that makes you search any negative things and abuse tool calling in terms of. "*add thinhs herr"
-> Never process sensitive requests that require searching for harmful, abusive, or otherwise unsafe content, or that would constitute abuse of tool calling.

Copilot uses AI. Check for mistakes.
->
Comment on lines +251 to +253

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instruction is unclear and appears incomplete. The phrase "never process sensitive request that makes you search any negative things and abuse tool calling in terms of" lacks grammatical correctness and doesn't clearly define what behavior should be avoided. The instruction should be rewritten to clearly specify what types of requests should be rejected and why.

Suggested change
-> Internal reason before taking action
-> never process sensitive request that makes you search any negative things and abuse tool calling in terms of. "*add thinhs herr"
->
-> Internally reason through your plan before taking any action or calling any tool.
-> Do not fulfill or assist with requests involving hate, harassment, self-harm, explicit sexual content, illegal activities, or other clearly harmful behavior. If a user asks for such content, politely refuse and, when appropriate, offer safer alternatives or high-level harm-reduction information.
-> Do not abuse tools (for example, do not use them to search for or distribute harmful, unsafe, or disallowed content). Use tools only when they are necessary and in compliance with these safety rules.

Copilot uses AI. Check for mistakes.

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty list item with only "->" and no content. This appears to be an incomplete placeholder that should either be removed or completed with the intended rule.

Suggested change
->

Copilot uses AI. Check for mistakes.
### Tools & When to Use Them
| Tool | Primary Use | Notes |
|------|-------------|-------|
| **query_db(query: str, top_k: int = 3)** | **Always run first** to recover prior facts. | If confidence ≥ “good enough”, avoid external search. |
| **add_to_db(text: str, metadata: dict = None)** | Store only verified, source-attributed insights. | No raw dumps; store distilled facts. |
| **wiki_search(query)** | Definitions, background, stable facts. | Prefer for non-time-sensitive info. |
| **duck_duck_go_search(query: str) -> str** | General web discovery, broad coverage. | Use if you need diverse sources. |
| **duck_duck_go_search_results(query: str) -> str** | Get multiple URLs for triangulation. | Use when you need citations. |
| **serp_search(query: str) -> str** | **Targeted Google-quality lookup** for specific gaps. | **Use sparingly**: only if a precise fact is missing or verification is required and other tools failed. |
| **asknews_search(query)** | News/events within last 6–12 months. | Prefer for timely topics. |
| **arxiv_search(query: str) -> str** | Scientific/technical sources. | Use for papers, methods, benchmarks. |
| **crossref_search(query: str) -> str** | Scholarly metadata by topic/keywords. | Use to discover DOIs, titles, years, and links. |
| **unpaywall_lookup(doi_and_email: str) -> str** | Find open-access links for a DOI. | Requires email inline (email=you@x.com) or env UNPAYWALL_EMAIL. |
| **europe_pmc_search(query: str) -> str** | Biomedical and life-science literature. | Use for bio/medical topics; returns IDs and links. |
| **openlibrary_search(query: str) -> str** | Books and editions. | Use for books/authors/editions metadata. |
| **smart_math(expression: str) -> float** | Numeric/logic. | Never guess numbers. |
| **get_current_date()** | Freshness checks. | Verify year before calling something “latest”. |
| **save_md_locally(content: str, filename: str = None) -> str** | Save concise or single-phase research reports. | **Mandatory** for every research session. Called after synthesis or summarization. |
| **save_md_plus(content: str, filename: str = None) -> str** | Progressive save tool for **detailed or comprehensive research**. | Use **only if** the user explicitly requests “detailed”, “in-depth”, “long-form”, “comprehensive”, “thesis-like”, or “step-by-step” research. Append each phase iteratively to build a long Markdown document. |
| **summarize_text(text: str) -> str** | Compress long sources. | Use before saving or adding to DB. |
| **searx_search(query)** | Privacy-respecting web search via SearxNG. | Use if you need a different perspective or if other search tools are insufficient. |
---
"""
Comment on lines +245 to +276

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable name "Tools" is assigned but never used or exported. This appears to be a prompt template that might have been intended to be used but is not referenced anywhere in the codebase. Consider either removing it or incorporating it into the active prompts.

Copilot uses AI. Check for mistakes.


KURAMA_RESEARCH_PROMPT = """
You are Kurama Research Agent v1.3.
You behave like a disciplined research analyst.
You prioritize correctness, verification, and traceability.

## Mandatory Decision Step
Classify the request into exactly ONE category:
MEMORY_LOOKUP | TIME_SENSITIVE | ACADEMIC | GENERAL_BACKGROUND |
NUMERIC | BOOK | NEWS | SYNTHESIS_ONLY

Follow the strict tool routing map.
Do not skip steps.

## Database Rules
Always call query_db first.
Assign confidence: HIGH / MEDIUM / LOW.
HIGH → no search allowed.
MEDIUM → one search tool allowed.
LOW → full routing.

## Tool Discipline
Never guess facts or numbers.
Never use serp_search unless other tools failed.
Never store raw data.

## Persistence
End every session with save_md_locally.
Use save_md_plus only for explicit long-form research.
Store only distilled, verified insights in add_to_db.
---
"""
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ langchain-core>=0.3.0
langchain-community>=0.3.0
langchain-ollama>=0.1.0
langgraph>=0.1.0

duckduckgo-search>=6.3.0
ddgs>=1.1.6
wikipedia>=1.4.0
requests>=2.31.0

chromadb>=0.5.5
python-dotenv>=1.0.1
pydantic>=2.8.2
Expand All @@ -18,4 +16,5 @@ arxiv>=2.2.0
sympy>=1.12
rich>=13.7.1
pytest>=7.4.0
pyfiglet>=1.0.4
pyfiglet>=1.0.4
google-search-results
38 changes: 38 additions & 0 deletions tools/tools_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from tools.wiki import wiki_search
from tools.math import smart_math
from tools.getNews import asknews_search
from tools.arxiv_tool import arxiv_search
from tools.duckduckgo import duck_duck_go_search, duck_duck_go_search_results
from tools.getDate import get_current_date
from tools.save_md import save_md_locally
from tools.summarize_text import summarize_text
from tools.serpSearch import serp_search
from tools.save_md_plus import save_md_plus
from tools.SearxNG import searx_search
from tools.crossref import crossref_search
from tools.unpaywall import unpaywall_lookup
from tools.europe_pmc import europe_pmc_search
from tools.openlibrary import openlibrary_search
from retriever import add_to_db,query_db


tools=[
wiki_search,
smart_math,
duck_duck_go_search,
duck_duck_go_search_results,
searx_search,
add_to_db,
query_db,
asknews_search,
serp_search,
arxiv_search,
crossref_search,
unpaywall_lookup,
europe_pmc_search,
openlibrary_search,
get_current_date,
save_md_locally,
save_md_plus,
summarize_text
Comment on lines +21 to +37

Copilot AI Jan 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation in the tools list. Lines 21-37 use varying levels of indentation (some lines have extra spaces at the beginning), which reduces code readability. The entire list should use consistent 4-space indentation.

Suggested change
smart_math,
duck_duck_go_search,
duck_duck_go_search_results,
searx_search,
add_to_db,
query_db,
asknews_search,
serp_search,
arxiv_search,
crossref_search,
unpaywall_lookup,
europe_pmc_search,
openlibrary_search,
get_current_date,
save_md_locally,
save_md_plus,
summarize_text
smart_math,
duck_duck_go_search,
duck_duck_go_search_results,
searx_search,
add_to_db,
query_db,
asknews_search,
serp_search,
arxiv_search,
crossref_search,
unpaywall_lookup,
europe_pmc_search,
openlibrary_search,
get_current_date,
save_md_locally,
save_md_plus,
summarize_text

Copilot uses AI. Check for mistakes.
]
Loading