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
9 changes: 3 additions & 6 deletions backend/src/core/cfg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ export const env = {
openai_model: process.env.OM_OPENAI_MODEL,
gemini_key:
process.env.GEMINI_API_KEY || process.env.OM_GEMINI_API_KEY || "",
aws_model: str(
process.env.AWS_REGION,
process.env.AWS_ACCESS_KEY_ID,
process.env.AWS_SECRET_ACCESS_KEY
),

AWS_REGION: process.env.AWS_REGION || "",
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || "",
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || "",
ollama_url: str(
process.env.OLLAMA_URL || process.env.OM_OLLAMA_URL,
"http://localhost:11434",
Expand Down
7 changes: 5 additions & 2 deletions backend/src/memory/hsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,9 @@ export async function expand_via_waypoints(
const neighs = await q.get_neighbors.all(cur.id);
for (const neigh of neighs) {
if (vis.has(neigh.dst_id)) continue;
const exp_wt = cur.weight * neigh.weight * 0.8;
// Clamp neighbor weight to valid range - protect against corrupted data
const neigh_wt = Math.min(1.0, Math.max(0, neigh.weight || 0));
const exp_wt = cur.weight * neigh_wt * 0.8;
if (exp_wt < 0.1) continue;
const exp_item = {
id: neigh.dst_id,
Expand Down Expand Up @@ -772,7 +774,8 @@ export async function hsg_query(
}
}
const em = exp.find((e: { id: string }) => e.id === mid);
const ww = em?.weight || 0;
// Clamp waypoint weight to valid range [0, 1] - protect against corrupted data
const ww = Math.min(1.0, Math.max(0, em?.weight || 0));
const ds = (Date.now() - m.last_seen_at) / 86400000;
const sal = calc_decay(m.primary_sector, m.salience, ds);
const mtk = canonical_token_set(m.content);
Expand Down