Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ BCG_GRAPH_START_TIMEOUT="120"
BCG_GRAPH_TIMEOUT_MS="300000"
BCG_RECENT_TURNS="2"

# Optional local RAG context tuning. The default database path is session-local
# under ~/.bcg/agent/rag; set BCG_RAG_DB_PATH only to override it.
BCG_RAG_DB_PATH=""
BCG_RAG_TOP_K="6"
BCG_RAG_MAX_CHARS="12000"

# Optional local GPU service profiles. These names are deliberately separate
# from MODEL, which is the remote/API model used by Agent rollouts.
VLLM_MODEL=""
Expand Down
17 changes: 11 additions & 6 deletions agent-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ Interactive terminal Agent for
The public command is `bcg`, provided by the Python package. This Node package
installs the internal `bcg-agent` runtime used by that launcher.

The runtime supports three session-level context modes. Default retains normal
full context with compaction. BCG and Summary both pin the initial user input,
retain a configurable number of recent completed turns, and evict older turns
in the same batches. BCG converts those batches into a belief graph; Summary
updates one rolling LLM summary. Either memory block is injected into the
system prompt.
The runtime supports five session-level context modes. Every bounded mode
permanently pins the initial user input and retains a configurable number of
recent completed turns:

- **Default** keeps the full conversation with automatic compaction.
- **Recent-Only** drops older turns and leaves the system prompt unchanged.
- **RAG** stores dropped turns in a session-local SQLite FTS5 database, queries
it with the recent raw turns, and injects retrieved history into the system
prompt.
- **Summary** compresses dropped turns into one rolling LLM summary.
- **BCG** converts dropped turns into a confidence-aware belief graph.

Configuration and sessions live under `~/.bcg/agent/`. API credentials can be
entered with `/login`; custom OpenAI-compatible endpoints use
Expand Down
10 changes: 5 additions & 5 deletions agent-cli/src/core/agent-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import {
prepareCompaction,
shouldCompact,
} from "./compaction/index.ts";
import { getSessionContextMode } from "./context/context-mode.ts";
import { getSessionContextMode, usesBoundedContext } from "./context/context-mode.ts";
import { DEFAULT_THINKING_LEVEL } from "./defaults.ts";
import { exportSessionToHtml, type ToolHtmlRenderer } from "./export-html/index.ts";
import { createToolHtmlRenderer } from "./export-html/tool-renderer.ts";
Expand Down Expand Up @@ -1776,8 +1776,8 @@ export class AgentSession {
*/
async compact(customInstructions?: string): Promise<CompactionResult> {
const contextMode = getSessionContextMode(this.sessionManager);
if (contextMode === "bcg" || contextMode === "summary") {
throw new Error("Traditional compaction is disabled in BCG and Summary modes.");
if (usesBoundedContext(contextMode)) {
throw new Error("Traditional compaction is disabled in bounded-context modes.");
}
this._disconnectFromAgent();
await this.abort();
Expand Down Expand Up @@ -1950,7 +1950,7 @@ export class AgentSession {
*/
private async _checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck = true): Promise<boolean> {
const contextMode = getSessionContextMode(this.sessionManager);
if (contextMode === "bcg" || contextMode === "summary") {
if (usesBoundedContext(contextMode)) {
return false;
}
const settings = this.settingsManager.getCompactionSettings();
Expand Down Expand Up @@ -2226,7 +2226,7 @@ export class AgentSession {
/** Whether auto-compaction is enabled */
get autoCompactionEnabled(): boolean {
const contextMode = getSessionContextMode(this.sessionManager);
return contextMode !== "bcg" && contextMode !== "summary" && this.settingsManager.getCompactionEnabled();
return !usesBoundedContext(contextMode) && this.settingsManager.getCompactionEnabled();
}

async bindExtensions(bindings: ExtensionBindings): Promise<void> {
Expand Down
12 changes: 11 additions & 1 deletion agent-cli/src/core/context/context-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ import type { ContextManagementProvider } from "../settings-manager.ts";

export const CONTEXT_MODE_ENTRY_TYPE = "bcg.context_mode";

export function usesBoundedContext(provider: ContextManagementProvider | undefined): boolean {
return provider === "bcg" || provider === "summary" || provider === "recent-only" || provider === "rag";
}

function isContextManagementProvider(value: unknown): value is ContextManagementProvider {
return value === "default" || value === "bcg" || value === "summary";
return (
value === "default" ||
value === "bcg" ||
value === "summary" ||
value === "recent-only" ||
value === "rag"
);
}

export function getSessionContextMode(sessionManager: SessionManager): ContextManagementProvider | undefined {
Expand Down
Loading
Loading