Skip to content

Fix stale deepseek-v4-flash pricing and build_merge docstring - #3173

Closed
adrianengkh wants to merge 1 commit into
Graphify-Labs:v8from
adrianengkh:fix/deepseek-pricing-and-build-merge-docstring
Closed

Fix stale deepseek-v4-flash pricing and build_merge docstring#3173
adrianengkh wants to merge 1 commit into
Graphify-Labs:v8from
adrianengkh:fix/deepseek-pricing-and-build-merge-docstring

Conversation

@adrianengkh

Copy link
Copy Markdown
Contributor

Two independent fixes, both verified against primary sources on 2026-08-29.

1. deepseek-v4-flash pricing is stale (graphify/llm.py)

The backend is priced at $0.14 / $0.28 per 1M tokens. That is DeepSeek V3 pricing. Per the published table, deepseek-v4-flash is:

off-peak peak
input (cache miss) $0.22 $0.44
output $0.66 $1.32

So estimate_cost under-reports a v4-flash run by roughly 3x on input and 4.7x on output. On a real corpus this is the difference between a run reading as free and reading as real money.

Changed to the peak/cache-miss rates, consistent with how the other backends here are priced (undiscounted list price). Added an inline note for the peak window (01:00-04:00 and 06:00-10:00 UTC Mon-Fri, all other hours half price) and the cache-hit rate, since neither is derivable from the two numbers alone.

2. build_merge docstring promises a write it never performs (graphify/build.py)

The docstring opens with "Load existing graph.json, merge new chunks into it, and save back." The function ends at return G. graph_path is only ever read.

Following the docstring leaves the on-disk graph silently unchanged — the call succeeds, the returned graph is correct, and nothing persists. I lost a merge to this before checking the source.

The runbooks already do the right thing (build_mergeclusterto_json), so this is a docs-only fix documenting the actual contract rather than a behaviour change — callers who already persist are unaffected.

Notes

No test asserts either value, so nothing in the suite changes. I was not able to run the full suite locally (no pytest in the environment I patched from) — happy to iterate if CI flags anything.

The deepseek backend was priced at $0.14/$0.28 per 1M tokens, which is
DeepSeek V3 pricing. deepseek-v4-flash is $0.44 in / $1.32 out at peak
(cache miss), half that off-peak, so estimate_cost under-reported a
v4-flash run by roughly 3x on input and 4.7x on output. Corrected against
the published table, with the peak window and cache-hit rate noted inline.

build_merge's docstring says it will 'save back', but the function only
returns the merged graph - graph_path is read-only and nothing is written.
Following the docstring leaves the on-disk graph silently unchanged.
Documented the actual contract and pointed at to_json as the save step.

Both values verified against the vendors' published pricing pages on
2026-08-29.

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Updates the DeepSeek v4-flash pricing in BACKENDS to the peak cache-miss rates ($0.44/$1.32 per 1M input/output tokens, up from $0.14/$0.28), so cost estimates now reflect worst-case pricing rather than off-peak/cache-hit rates. Also clarifies that build_merge returns the merged graph in memory without writing to disk, leaving persistence to the caller.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 1487 functions depend on the 252 functions this change touches.

Health — this change adds coupling hotspots:

  • new: _rebuild_code() — 98 callers, 50 callees
  • new: build_from_json() — 190 callers, 18 callees
  • new: deduplicate_entities() — 63 callers, 21 callees
  • new: build_merge() — 53 callers, 13 callees
  • new: to_obsidian() — 36 callers, 13 callees
  • new: extract_files_direct() — 17 callers, 20 callees
  • new: to_wiki() — 41 callers, 7 callees
  • new: extract_corpus_parallel() — 26 callers, 11 callees
  • …and 50 more — each is listed as a finding

Verification — 1487 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 1247 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify build\_merge.

The verifier did not have enough to check build\_merge, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `graph_path` is annotated `str | Path | None` — outside the synthesizable primitive/collection set

· 58 more finding(s) on lines outside this diff (see the check run).

@safishamsi

Copy link
Copy Markdown
Collaborator

Shipped in v0.9.52 via authorship-preserving cherry-pick so you keep contributor-graph credit. Thanks @adrianengkh! Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52

@safishamsi safishamsi closed this Aug 29, 2026
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.

2 participants