K-Dense BYOK

repository·main·Indexed 21 days ago

https://github.com/k-dense-ai/k-dense-byok

An open-source AI research assistant named Kady designed for scientists to perform data analysis, literature review, and scientific writing. It features a local-first, privacy-preserving workspace where users can bring their own AI API keys (OpenRouter), subscriptions (ChatGPT, Claude, xAI, GitHub Copilot), or local models (Ollama). Kady includes 149 scientific skills, 326 guided workflows, and support for 60+ scientific file formats, including 3D protein structures and DICOM/NIfTI images.

Tokens
37.9K
Snippets
80
Records
165
Agent score
76%

What's inside k-dense-byok

  1. Overview of K-Dense BYOK

    main

    K-Dense BYOK (Bring Your Own Keys) is an open-source AI research assistant named Kady designed for scientists. It allows users to describe research tasks in plain language (e.g., analyze this dataset, review my manuscript) and executes them within a local research workspace.

    Key characteristics:

    • No coding required: Kady writes and runs the necessary analysis code automatically.
    • Local-first privacy: Projects, conversations, and notebooks are stored in ordinary folders on your local machine. K-Dense does not host or store your data.
    • Flexible Compute: You can use your own AI subscriptions (ChatGPT, Claude, etc.), hosted API providers (OpenRouter), or free local models (Ollama) to power the assistant.
  2. Security considerations for the local shell trust boundary

    main

    Kady's agent has access to a powerful local shell to install packages and run analyses. This shell runs as your current operating-system user.

    Critical Security Notes:

    • No OS-level isolation: The shell is not a security boundary. A process running as you can read your own .env files, ~/.kady directory, and other local secrets.
    • Adversarial Files: Do not ask Kady to process untrusted files that may contain prompt injections designed to access your local secrets.
    • Recommended Isolation: Use an OS sandbox, container, VM, or a separate user account when working with untrusted content.
    • Skill Security: Installing a skill from a third-party source is equivalent to running code from that source. Review third-party skills before installation and prefer pinning to a specific branch or tag.
  3. Manage chat tabs and workflow launching

    main

    Kady uses a tabbed interface for chats with the following constraints:

    • Tab Limit: There is a hard cap of 10 tabs per project. To open a new tab once this limit is reached, you must close an existing one.
    • Persistence: Browser refreshes and tab closures preserve workspaces, chat tabs, drafts, queues, and live turns. However, stopping or restarting the Kady backend will end in-flight turns (though completed history remains on disk).
    • Workflow Launching: Workflows always launch into the currently active tab. If you have a long-running task in Tab A and want a new workflow to run in Tab B, you must switch to Tab B before clicking 'Launch'.
  4. Understand how Kady executes tasks

    main

    Kady operates as an autonomous researcher using several core mechanisms:

    • Interactive Clarification: If a task is ambiguous, Kady will pause and present an interactive question form (multiple choice, free text, or image upload) in the chat for you to confirm or skip.
    • Code Execution: Analyses are performed in a project sandbox using Python (managed via uv). You can inspect, modify, or re-run the generated code.
    • Skill Activation: Kady automatically selects from 140+ pre-installed scientific skills (genomics, proteomics, etc.).
    • Sub-agent Delegation: Kady can delegate complex or parallel work to 21 specialized sub-agents (e.g., citation-checker, statistical-reviewer, peer-reviewer). You can trigger them manually: "have the citation-checker go through manuscript.md".
    • Web & Source Access: Kady can search the web and read pages, PDFs, GitHub repositories, and YouTube videos. Direct provider access (Exa, Perplexity, Gemini) requires optional API keys.
    • Structured Results: Results are presented as typed cards in the chat (tables, plots, statistical tests, etc.). These cards link to the underlying sandbox artifacts for previewing.
  5. Manage Research Projects and Workspaces

    main

    K-Dense BYOK uses independent research workspaces called Projects.

    • Isolation: Each project has its own files, chats, notebooks, model choices, and spending policies.
    • Parallelism: You can run multiple projects simultaneously. Within a single project, you can use up to 10 parallel chat tabs, each with its own conversation, model, and cost, while sharing the same project files.
    • Persistence: The workspace state (open files, panel sizes, active turns) is restored after browser refreshes or closures. A live turn will reconnect to the running backend.
    • Local Storage: All work is stored in ordinary local files, making projects easy to back up, move, or archive.
  6. Manage parallel chats with Chat Tabs

    main

    Kady supports up to 10 parallel chat tabs within a single project:

    • Creation: Click + in the chat tab strip to open a new chat.
    • Isolation vs. Sharing: Each tab maintains its own message history, model choice, attached files, and cost meter. However, all tabs share the project's files, meaning files produced in one chat are immediately available in others.
    • Background Processing: Tabs continue working in the background even when you switch to a different tab.
    • Management: Double-click a tab title to rename it. Closing a tab cancels any active work in that tab.
  7. Choose and configure model access

    main

    Kady supports three main ways to access AI models:

    1. OpenRouter: Provides pay-as-you-go access to models from OpenAI, Anthropic, Google, etc. Requires an API key starting with sk-or-....
    2. Pi OAuth subscriptions: Connect existing subscriptions for ChatGPT Plus/Pro (openai-codex), Claude Pro/Max (anthropic), GitHub Copilot (github-copilot), or xAI (xai). To connect, go to Settings $\rightarrow$ Model providers in the app and click Connect.
    3. Local Ollama: Run free local models without hosted-provider credentials.

    Important: OpenRouter-only features (like OpenRouter Fusion and server-side speech transcription) require an OpenRouter API key even if you have a Pi subscription.

  8. Understand Pi subscription provider boundaries

    main

    Kady supports Pi OAuth for several providers (OpenAI Codex, Anthropic, GitHub Copilot, and xAI), but there are important usage boundaries:

    • Quota Management: Kady cannot read your remaining subscription quota or plan eligibility. A successful login does not guarantee unlimited usage.
    • Billing/Pricing: For OpenAI Codex, Copilot, and xAI, Kady tracks tokens and Pi's list-price equivalent for project spend caps, but this is not an actual invoice.
    • Anthropic Specifics: Anthropic OAuth is treated as metered extra per-token usage. Kady treats this amount as project spend and applies your defined cap.
    • Authentication: Direct-provider API keys (Ambient OpenAI, Anthropic, etc.) are treated as standard API-key paths, not subscription access. To use subscription access, you must use the OAuth flow. To use API keys, use OpenRouter.
    • Feature Availability: Some features like Fusion and server-side speech transcription require OpenRouter and are not supported via subscription logins.
  9. How subagent work is recorded

    main

    Work performed by subagents (child pi processes) is reconstructed and appended to the parent's log. These steps are marked with role: "subagent" and include the specialist's name and the child's specific model.

    Subagent Provenance Characteristics

    • Identity at Harvest: Because subagent work is inspected after completion, bytes are hashed at the time of harvest rather than at the time of write. These are marked with identityAt: "harvest" and may be reported as Unverified in staleness reports.
    • Write Attribution: Since the parent cannot see the 'before' state of a child process, harvested writes use the wrote keyword instead of created or modified.
    • Bash in Subagents: bash commands inside a subagent cannot be scan-attributed because the sandbox has moved on by the time the parent inspects the results. These are marked with degraded: "no-scan-baseline". Files produced by these commands are attached to the child's last opaque call as an inferred edge.
  10. Understand budget reservations and costs

    main

    To prevent overspending, K-Dense reserves a worst-case estimate before creating Modal resources using the formula:

    estimated hourly rate × requested timeout

    Admission Control: New jobs are blocked if settled project spend + open reservations + new reservation exceeds the hard project cap.

    Cost UI Terms:

    • spent: Settled model and compute estimates.
    • reserved: Worst-case holds for active Modal jobs.
    • committed: The sum of spent and reserved.
  11. Detecting stale artifacts via provenance

    main

    Provenance tracks whether the current bytes on disk match the bytes that existed when a tool produced them. This prevents citations in lab notebooks from silently pointing to incorrect data after a file has been regenerated.

    Staleness Statuses:

    • Current: The bytes on disk match the producing step's recorded hash.
    • Stale: The file has changed since the step that produced it.
    • Unverified: No hash is available to compare against (e.g., due to size limits or harvest timing); sameness is not confirmed.
  12. How chat tabs and sessions are managed

    main

    In the UI, every chat tab corresponds to a unique backend session.

    Session Scope (Per-Tab)

    Each session maintains its own:

    • Message history: Stored as a Pi JSONL file in projects/<project>/sandbox/.pi/sessions/.
    • Model selection: The specific model assigned to that tab.
    • Context: Attached files and the queued-message buffer.
    • Cost ledger: Individual spending tracked in projects/<project>/sandbox/.kady/runs/<sessionId>/costs.jsonl.
    • Live subscription: A streaming connection via the backend run broker. Refreshing the browser reattaches to the existing turn.

    Project Scope (Shared across tabs)

    All tabs within a single project share:

    • The Sandbox: The directory projects/<project>/sandbox/. Files created by one tab are immediately visible to all other tabs in the same project.
    • Project Settings: The budget cap (spendLimitUsd) and the total project cost.
    • Authentication: API keys and global preferences from the root .env file, and the shared Pi OAuth store.