Commit Graph

5133 Commits

Author SHA1 Message Date
Henri Jamet
1fd6e16cff Improve Obsidian Batch Sync. Show Progress, Storage Used on Settings Page (#1221)
### **feat(obsidian): Enhance Sync Experience with Progress Bars and Bug
Fixes**

This pull request significantly improves the content synchronization
experience for Obsidian users by fixing a critical bug and introducing
new UI elements for better feedback and monitoring.

The previous implementation could fail with `403 Forbidden` errors when
syncing a large number of files due to server-side rate limiting. This
update addresses that issue and provides users with clear, real-time
feedback on storage usage and sync progress.

---
### Key Changes

* **Improve Sync Robustness**
Refactor `updateContentIndex` to sync files prioritized by file type (md
> pdf > image) and batched by size (10Mb) and item limits (50 items).
This respects server rate limits and ensures that large vaults can be
indexed reliably without triggering `403` errors.

* **Show Cloud Storage Usage Bar**
A progress bar has been added to the settings page to display cloud
storage usage.
* **Total Limit**: The storage limit (**10 MB** for free, **500 MB** for
premium) is now reliably determined by the `is_active` flag returned
from the `/api/v1/user` endpoint, eliminating fragile client-side
heuristics.
* **Used Space**: The used space is calculated via a **client-side
estimation** of all files configured for synchronization. This provides
a clear and immediate indicator of the vault's storage footprint.

* **Show Real-time Sync Progress Bar**
When a manual sync is triggered via the "Force Sync" button, a progress
bar now appears, providing real-time feedback on the operation.
* It displays the number of files processed against the total number of
files to be indexed or deleted.
* This is implemented using a **callback mechanism** (`onProgress`) to
cleanly communicate progress from the sync logic (`utils.ts`) to the UI
(`settings.ts`) without coupling them.

* **Auto-refresh Storage Used After Sync**
The Cloud Storage Usage bar is now automatically refreshed upon the
completion of a "Force Sync". This ensures the user immediately sees the
updated storage estimation without needing to reopen the settings panel.

---
### Visuals

<img width="980" height="237" alt="image"
src="https://github.com/user-attachments/assets/2b3ce420-766b-476f-9fc0-c6b38c0226fb"
/>

---------

Co-authored-by: Debanjum <debanjum@gmail.com>
2026-01-03 13:04:46 +05:30
sabaimran
d6c2d1fa49 Give Khoj Long Term Memories (#1168)
# Motivation
A major component of useful AI systems is adaptation to the user
context. This is a major reason why we'd enabled syncing knowledge
bases. The next steps in this direction is to dynamically update the
evolving state of the user as conversations take place across time and
topics. This allows for more personalized conversations and to maintain
context across conversations.

# Overview
This change introduces medium and long term memories in Khoj. 
- The scope of a conversation can be thought of as short term memory. 
- Medium term memory extends to the past week.
- Long term memory extends to anytime in the past, where a search query
results in a match.

# Details
- Enable user to view and manage agent generated memories from their
settings page
- Fully integrate the memory object into all downstream usage, from
image generation, notes extraction, online search, etc.
- Scope memory per agent. The default agent has access to memories
created by other agents as well.
- Enable users and admins to enable/disable Khoj's memory system

---------

Co-authored-by: Debanjum <debanjum@gmail.com>
2026-01-03 09:07:05 +05:30
Debanjum
d55a00288b Release Khoj version 2.0.0-beta.24 2026-01-01 19:59:10 -08:00
Debanjum
ff4b9f3502 Render mermaid diagram wrapped in markdown codeblocks on web app 2026-01-01 19:57:49 -08:00
Debanjum
19900e42ef Fix registering subscription payment failures 2026-01-01 19:57:49 -08:00
Debanjum
a58ae3dd84 Make LLM actors write & code sandbox check for artifacts in /home/user
Fix
- Ensure researcher and coder know to save files to /home/user dir
- Make E2B code executor check for generated files in /home/user
- Do not re-add file types already downloaded from /home/user

Issues
- E2B has a mismatch in default home_dir for run_code & list_dir cmds
So run_code was run with /root as home dir. And list_dir("~") was
checking under /home/user. This caused files written to /home/user
by code not to be discovered by the list_files step.
- Previously the researcher did not know that generated files should
be written to /home/user. So it could tell the coder to save files to
a different directory. Now the researcher knows where to save files to
show them to user as well.
2025-12-29 14:57:37 -08:00
Debanjum
b607a6187e Release Khoj version 2.0.0-beta.23 2025-12-29 01:42:25 -08:00
Boris Smus
f413ce7354 Enable excluding folders to sync from obsidian plugin settings (#1235)
- Add excludeFolders field to KhojSetting interface
- Rename 'Sync Folders' to 'Include Folders' for clarity
- Add 'Exclude Folders' UI section with folder picker
- Filter out excluded folders during content sync
- Show file counts when syncing (X of Y files)
- Prevent excluding root folder

This allows users to exclude specific directories (e.g., Inbox,
Highlights) from being indexed, while the existing Include Folders acts
as a whitelist.

---------

Co-authored-by: Debanjum <debanjum@gmail.com>
2025-12-29 15:09:19 +05:30
Debanjum
9b9cdc756f Capture more files generated by code execution in sandbox
This change had been removed in 9a8c707 to avoid overwrites. We now
use random filename for generated files to avoid overwrite from
subsequent runs.

Encourage model to write code that writes files in home folder to
capture with logical filenames.
2025-12-29 00:57:17 -08:00
Debanjum
c5650f166a Make Nano Banana Pro output 2K resolution images 2025-12-29 00:57:17 -08:00
Debanjum
1b7ccd141d Harden the user check of the Notion integration 2025-12-29 00:57:17 -08:00
Debanjum
b8eeefa0b1 Bump web app package dependencies 2025-12-29 00:57:17 -08:00
Debanjum
9801ffd2de Add Khoj app landing page. Show it when unauthenticated users open app
Add khoj app landing page to khoj monorepo. Show in a more natural
place, when non logged in users open the khoj app home page.

Authenticated users still see logged in home page experience.
2025-12-29 00:57:17 -08:00
Debanjum
5e65754a8b Unify login via popup on home. No need for separate login html page.
Delete old login html page. Login via popup on home is the single,
unified login experience.

Have docs mention khoj home url, no need to mention /login as login
popup shows on home page too
2025-12-29 00:57:17 -08:00
Debanjum
f65f6ae848 Fix streaming thoughts from multi-turn tools after parallel tool calling
Single turn tools are still executed in parallel. Multi turn tools
like operator are executed in serial.
2025-12-29 00:57:17 -08:00
Debanjum
446a23524c Remove trial subscriptions from Khoj cloud 2025-12-16 16:23:47 -08:00
Debanjum
cdcbdf8459 Execute tool calls in parallel to make research iterations faster 2025-12-13 22:55:54 -08:00
Debanjum
054ed79fdf Allow LLMs to make parallel tool call requests
Why
--
- The models are now smart enough to usually understand which tools to
  call in parallel and when.

- The LLM can request more work for each call to it, which is usually
  the slowest step. This speeds up work by reearch agent. Even though
  each tool is still executed in sequence (for now).
2025-12-13 21:37:49 -08:00
Debanjum
f4c519a9d0 Release Khoj version 2.0.0-beta.22 2025-12-07 20:32:28 -08:00
Debanjum
6480e99266 Upgrade server, documentation dependencies 2025-12-07 20:29:11 -08:00
Debanjum
181332dcb8 Improve Claude context caching to improve response cost, intelligence
Old thought messages are dropped by default by the Anthropic API. This
change ensures old thoughts are kept. This should improve cache
utilization to reduce costs. And keeping old thoughts may also improve
model intelligence.
2025-12-07 20:23:58 -08:00
Debanjum
9c03af2735 Disable parallel tool call by anthropic models as unsupported
Khoj doesn't handle parallel tool calling right now. Models were told
to call tools in serial but it wasn't enforced via the Anthropic API.
So if model did try make parallel tool call, next response would fail
as it expects a tool result for the other tool calls. But khoj just
returned the first tool calls results. This mostly affected haiku due
to its lower fine-grained instruction following capabilities.

This changes enforces serial tool calls at the API layer to avoid this
issue altogether for claude models.
2025-12-07 20:23:58 -08:00
Debanjum
4654ac4962 Enable reasoning for Claude Haiku 4.5. Track costs of Opus 4.5 2025-12-07 20:23:58 -08:00
Debanjum
f1337c3b07 Handle unset event in chat response stream
Testing unset event field is an edge case that would unnecessarily
prematurely terminate stream. Ignoring it stabilizes response stream
completion.
2025-12-07 20:23:58 -08:00
Debanjum
bdf9afa726 Set openai api output tokens high by default to not hit length limits
Explicitly set completion tokens high to avoid early termination
issues, especially when trying to generate structured responses.
2025-12-07 20:23:58 -08:00
Debanjum
5b6dab1627 Use consistent summarizer result for failed research iteration 2025-12-05 10:02:08 -08:00
Debanjum
3941159bd6 Release Khoj version 2.0.0-beta.21 2025-11-29 17:31:14 -08:00
Debanjum
e2340c709f Fix extracting image by URL in chat history when using Nano Banana Pro
Logical error due to else conditional being not correctly indented.
This would result in error in using gemini 3 pro image when images are
in S3 bucket.
2025-11-29 17:08:17 -08:00
Debanjum
856864147b Drop image generation support for Stability AI models
Reduces maintenance burden by dropping support for old ai model
providers
2025-11-29 17:08:11 -08:00
Debanjum
c41e37d734 Release Khoj version 2.0.0-beta.20 2025-11-29 16:12:38 -08:00
Debanjum
731700ac43 Support fallback deep, fast chat models via server chat settings
Overview
---
This change enables specifying fallback chat models for each task
type (fast, deep, default) and user type (free, paid).

Previously we did not fallback to other chat models if the chat model
assigned for a task failed.

Details
---
You can now specify multiple ServerChatSettings via the Admin Panel
with their usage priority. If the highest priority chat model for the
task, user type fails, the task is assigned to a lower priority chat
model configured for the current user and task type.

This change also reduces the retry attempts for openai chat actor
models from 3 to 2 as:
- multiple fallback server chat settings can now be created. So
  reducing retries with same model reduces latency.
- 2 attempts is inline with retry attempts with other model
  types (gemini, anthropic)
2025-11-29 15:57:35 -08:00
Debanjum
99f16df7e2 Use fast model in default mode and for most chat actors
What
--
- Default to using fast model for most chat actors. Specifically in this
  change we default to using fast model for doc, web search chat actors
- Only research chat director uses the deep chat model.
- Make using fast model by chat actors configurable via func argument

Code chat actor continues to use deep chat model and webpage reader
continues to use fast chat model.

Deep, fast chat models can be configured via ServerChatSettings on the
admin panel.

Why
--
Modern models are good enough at instruction following. So defaulting
most chat actor to use the fast model should improve chat speed with
acceptable response quality.

The option to fallback to research mode for higher quality
responses or deeper research always exists.
2025-11-29 15:57:35 -08:00
Debanjum
da493be417 Support image generation with Gemini Nano Banana 2025-11-29 15:57:35 -08:00
Debanjum
dd4381c25c Do not try render invalid image paths in message on web app
Avoids rendering flicker from attempt to render invalid image paths
referenced in message by khoj on web app.

The rendering flicker made it very annoying to interact with
conversations containing such messages on the web app.

The current change does lightweight validation of image url before
attempting to render it. If invalid image url detected, the image is
replaced with just its alt text.
2025-11-29 15:23:51 -08:00
Debanjum
51b893d51d Fix to ensure rectangular generated images are not cropped on web app
Previously non-square images would get cropped when being displayed on
web app
2025-11-29 15:23:51 -08:00
Debanjum
32966646e2 Avoid ai hover summaries in vscode dev env for now 2025-11-29 15:23:51 -08:00
Debanjum
043777c1bd Release Khoj version 2.0.0-beta.19 2025-11-18 15:30:50 -08:00
Debanjum
47a55c20a0 Associate folder icon with all doc tools use in thinking UX on web app
The newer grep_files and list_files should also be associated with
document search in train of thought visualization on the web app.
2025-11-18 15:17:38 -08:00
Debanjum
6459150870 Upgrade packages for documentation and desktop app 2025-11-18 15:17:38 -08:00
Debanjum
03dad1348a Support Minimax M2. Extract its thinking from response
- Use qwen style <think> tags to extract Minimax M2 model thoughts
- Use function to mark models that use in-stream thinking (including
  Kimi K2 thinking)
2025-11-18 14:13:28 -08:00
Debanjum
57d6ebb1b8 Support Google Gemini 3
- Use thinking level for gemini 3 models instead of thinking budget.
- Bump google gemini library
- Add default context, pricing
2025-11-18 14:13:24 -08:00
Debanjum
a30c5f245d Skip non-serializable, binary content parts when token counting 2025-11-18 12:42:18 -08:00
Debanjum
ec31df7154 Test khoj.el with more recent emacs versions 2025-11-18 10:29:02 -08:00
Debanjum
895af42039 Fix unbound response var exception in agent safety checker 2025-11-18 10:29:02 -08:00
Debanjum
748a4f9941 Release Khoj version 2.0.0-beta.18 2025-11-16 11:08:44 -08:00
Debanjum
3496189618 Support using MCP tools in research mode
- Server admin can add MCP servers via the admin panel
- Enabled MCP server tools are exposed to the research agent for use
- Use MCP library to standardize interactions with mcp servers
  - Support SSE or Stdio as transport to interact with mcp servers
  - Reuse session established to MCP servers across research iterations
2025-11-16 10:50:30 -08:00
Debanjum
2ac7359092 Simplify webpage read function names and drop unused return args 2025-11-16 10:50:30 -08:00
Debanjum
f1a34f0c2a Prefer Exa for web search over Google, Firecrawl
Google and Firecrawl do not provide good web search descriptions (within
given latency requirements). Exa does better than them.

So prioritize using Exa over Google or Firecrawl when multiple web
search providers available.
2025-11-16 10:50:30 -08:00
Debanjum
45f4253120 Move Olostep scraping config into its webpage reader for cleaner code 2025-11-16 10:50:30 -08:00
Debanjum
e6a5d3dc3d Deprecate support for using Firecrawl webpage summarizer
Better speed and control by using Khoj webpage summarizer. Reduce code
cruft by clearing unused features.
2025-11-16 10:50:30 -08:00