Skip to content

chore: sync main into staging (agentic per-doc cap + doc-agent) - #250

Open
EricNGOntos wants to merge 11 commits into
stagingfrom
main
Open

chore: sync main into staging (agentic per-doc cap + doc-agent)#250
EricNGOntos wants to merge 11 commits into
stagingfrom
main

Conversation

@EricNGOntos

Copy link
Copy Markdown
Contributor

Summary

Why

Staging Notebook (https://notebook.staging.knowhereto.ai/) talks to https://api-staging.knowhereto.ai, which currently still runs 03374ffe (2026-08-03) and does not include #248/#246.

Test plan

  • CI green on this staging promotion PR
  • Confirm staging deploy workflow runs after merge
  • GET https://api-staging.knowhereto.ai/v1/version shows a commit containing refactor: scale agentic budget by flat per-doc caps #248 (66fe1b0f or descendant)
  • Smoke agentic retrieval from notebook.staging

Made with Cursor

gdccyuen and others added 8 commits August 3, 2026 15:38
#236)

When last_context (the preceding markdown text) is very long, the
generated image filename exceeds the OS 255-byte limit and os.rename
fails with OSError ENAMETOOLONG. Truncate to 60 chars after sanitization.
* fix: share one 80-char cap for image and table asset filenames

Unify the post-#236 image context truncate with table header naming so
cosmetic asset stems use a single MAX_ASSET_FILE_NAME_CHARS constant.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: handle None from path_handle before truncating image titles

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Dashboard still sends result_mode in job creation requests but the
API removed it. Add to _PUBLIC_COMPATIBILITY_EXTRA_FIELDS so it's
silently ignored instead of rejecting the whole request with 400.
- Added DOC_PROFILE_FILENAME to persist anatomy map artifacts for better debugging.
- Updated hierarchy_locator to retain original TOC headings while normalizing titles.
- Introduced TOC_VLM_MAX_TOKENS for consistent token limits in VLM calls.
- Refactored rendering logic in extract_toc_with_boundaries to handle multiple pages.
- Improved evidence extraction from confirmation items in VLM processing.
- Adjusted zip package writer to conditionally include TOC hierarchies based on parse track.
- Removed the obsolete 'verdict_now' action, consolidating decision-making under 'tool_call'.
- Updated prompts and instructions to clarify the executor's role in handling actions and verdicts.
- Enhanced the handling of legacy actions to ensure compatibility with the new decision structure.
- Refactored the logic in the executor to enforce 'tool_call' as the only valid action, improving clarity and maintainability.
- Adjusted the planner's behavior to treat 'verdict_now' as a non-finish signal, delegating success/abort handling to the executor.
refactor: document-agent profile protocol and TOC boundary tools
Replace chunk-weighted per-doc min shares with a flat per-doc cap, and grow planning/context plus wallet totals after document selection so spendable budget tracks the selected set.

Co-authored-by: Cursor <cursoragent@cursor.com>
refactor: scale agentic budget by flat per-doc caps
)
from app.services.document_agent.planner.planner import _parse_profile_and_decision
from app.services.document_agent.registry import REGISTRY
from app.services.document_agent import tools as _registered_tools # noqa: F401
EricNGOntos and others added 2 commits August 11, 2026 15:32
Classic path/content channels loaded the full scoped corpus into Python
before BM25. Prefetch via simple FTS (server-side OR tsquery), apply
section exclusions before the candidate LIMIT, and fall back to a full
scan when FTS matches nothing so recall does not regress. Combines the
approaches from #244 and #251; closes #195.

Co-authored-by: Ray Tien <ray.tien0907@gmail.com>
Co-authored-by: nuemaan <anonnumaan@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor: update retrieval architecture and agentic mode handling

- Reorganized the retrieval flowchart to enhance clarity and structure.
- Introduced new retrieval modes: classic top-K and map-nav, with clear descriptions for each.
- Updated the `use_agentic` parameter to default to map-nav, simplifying user experience.
- Removed legacy agentic components and related tests to streamline the codebase.
- Adjusted documentation to reflect changes in retrieval modes and internal structures.

* perf: bound classic BM25 candidates with Postgres FTS

Classic path/content channels loaded the full scoped corpus into Python
before BM25. Prefetch via simple FTS (server-side OR tsquery), apply
section exclusions before the candidate LIMIT, and fall back to a full
scan when FTS matches nothing so recall does not regress. Combines the
approaches from #244 and #251; closes #195.

Co-authored-by: Ray Tien <ray.tien0907@gmail.com>
Co-authored-by: nuemaan <anonnumaan@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: green CI for mapnav PR (lint, pyright, demo classic path)

Exclude vendored nav/ from pyright, tighten mapnav plan typing, and force
demo contract retrieval onto classic so CI does not hit a live LLM.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Ray Tien <ray.tien0907@gmail.com>
Co-authored-by: nuemaan <anonnumaan@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Back-compat aliases for tests / callers.
_evidence_owner_section_id = evidence_owner_section_id
_unit_score_for_evidence_chunk = unit_score_for_evidence_chunk


# Back-compat name used by older tests; prefer _mark_collected_branch.
_update_collect_coverage = _mark_collected_branch
result = json.loads(text)
if isinstance(result, list):
return [str(item) for item in result if str(item) in valid_ids]
except (ValueError, json.JSONDecodeError):
result = json.loads(fence_match.group(1).strip())
if isinstance(result, list):
return [str(item) for item in result if str(item) in valid_ids]
except (ValueError, json.JSONDecodeError):
result = json.loads(bracket_match.group())
if isinstance(result, list):
return [str(item) for item in result if str(item) in valid_ids]
except (ValueError, json.JSONDecodeError):

def roots(self, doc_id: str) -> Sequence[str]:
"""Top-level section ids for a document (or corpus root)."""
...

def children(self, section_id: str) -> Sequence[str]:
"""Direct child section ids, in document order."""
...

def node_meta(self, section_id: str) -> NodeMeta:
"""Title/summary/chunk-count/has_children for one node."""
...

def relations(self, section_id: str) -> Tuple[Set[str], Set[str]]:
"""(ancestor_ids, descendant_ids); section_id itself excluded from both."""
...

def content(self, section_id: str) -> str:
"""Full text for this node's subtree, as one evidence unit."""
...
…c leftovers (#254)

Fall back to provider structure summaries when the section store is absent,
make map_mode config-authoritative, and remove unused llm_adapter/old mocks.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants