[Bug]: lakeview's trajectory is never recorded, so the tagger and the extractor are prompted with an empty history
What happened?
Lakeview asks the model to reason about a trajectory it is never shown. trae_agent/utils/lake_view.py:86 initialises self.steps: list[str] = [] and nothing in the repository ever appends to it, while three places read it — so the tagger is prompted with "Below is the trajectory of an AI agent solving a software bug until the current step. Each step is marked within a <step> tag." and receives zero <step> blocks, and the extractor's <previous_step> is always the literal string (none).
Measured on main @ e839e55 by replacing only lakeview_llm_client with a recorder and feeding three consecutive real AgentStep objects through create_lakeview_step:
after agent step 1: self.steps has 0 entries | <previous_step> = (none) | <step id=...> blocks the tagger is told about = 0
after agent step 2: self.steps has 0 entries | <previous_step> = (none) | <step id=...> blocks the tagger is told about = 0
after agent step 3: self.steps has 0 entries | <previous_step> = (none) | <step id=...> blocks the tagger is told about = 0Nothing crashes and the panel still renders, which is why it has gone unnoticed: every step still gets a LakeViewStep, just one produced from an empty trajectory. The cost is two degraded LLM calls per agent step on a feature that is on by default.
What did you expect to happen?
Two things, both of which the code at hand is written to do but cannot:
extract_tag_in_step(lake_view.py:139-141) should see the steps that came before this one, since that is what its own prompt claims to be sending.create_lakeview_step(lake_view.py:195-197) should pass the immediately preceding step into the extractor as<previous_step>, so the extractor can tell "still reading the same file" apart from "moved on to writing the fix".
Evidence that this is the intended behaviour, not a design choice
Three independent signals in the file itself:
lake_view.py:143guardsif len(steps_fmt) > 300_000: # step_fmt is too long, skip tagging. That guard protects against a length an empty string can never reach — it only makes sense ifself.stepswas meant to be filled.lake_view.py:139-141numbers the entries (<step id="{ind + 1}">), which is pointless for a list that is always empty.lake_view.py:195-196keeps an explicit"(none)"placeholder for the case of "no previous step yet", which distinguishes "first step" from "we have history but did not record it".
History
This is not a regression introduced by a later refactor — it has never worked. git log -S "self.steps.append" -- trae_agent/utils/lake_view.py returns nothing across the file's entire six-commit history, and the commit that introduced the feature (4bf1473, "Multiple enhancements: Lakeview, Azure Client, retry for model providers") already contained the read-without-write shape:
88: self.steps: list[str] = []
148: steps_fmt = '\n\n'.join(f'<step id="{ind+1}">\n{s.strip()}\n</step>' for ind, s in enumerate(self.steps))
211: if len(self.steps) > 1:
212: previous_step_str = self.steps[-1]grep -rn "steps.append" trae_agent/ matches exactly one line, trae_agent/agent/base_agent.py:244 (execution.steps.append(step)) — a different list on a different object.
A second, latent defect on the same line
lake_view.py:196 reads if len(self.steps) > 1:. Even once appends exist, at the second agent step self.steps holds exactly one entry, so > 1 is false and <previous_step> would still be (none). The condition needs to be non-empty, not longer-than-one. Any fix that only adds the append leaves this half-broken.
Traceback
No response — there is no exception. The failure is silent: the model answers confidently about a trajectory that is not there.
What is your system, Python, dependency version?
main @ e839e55 (the repository's last commit, 2026-02-05), Python 3.12, Windows. The reproduction needs no network, no API key and no Docker daemon — the LLM client is replaced by a recorder before either call happens.
Lakeview is on by default, so this is not an opt-in corner: trae_agent/utils/config.py:164 sets enable_lakeview: bool = True, trae_agent/agent/agent.py:52-54 passes the LakeviewConfig to the console, and trae_agent/utils/cli/simple_console.py:227 calls create_lakeview_step for every recorded step.
Additional information that you believe is relevant to this bug
- The fix is two lines inside
create_lakeview_step: use the non-empty check forprevious_step_str, and appendthis_step_strtoself.stepsafter the two extraction calls (before them would put the current step in the trajectory and in<current_step>, duplicating it). - There is no test file for this module at all —
grep -rl "lake_view\|LakeView" tests/returns nothing — so nothing here has ever been machine-checked. - For transparency about existing work: the bulk PRs #434 (
升级, 66 files, +5006), #435 (Trae/agent pe xg kc, 55 files, +3674) and #437 (Fix/multi issue cleanup 2, 61 files, +4223) each do containself.steps.append(this_step_str). This defect is reported and fixed here on its own, with a regression test, rather than inside a multi-thousand-line change. #428 changes a different line of the same file (matched_tags[0]raisingIndexError) and does not touchself.steps. - One consequence worth deciding on before merging: once the trajectory is real, each tagger call carries everything before it, so per-step prompt size grows with the run.
lake_view.py:143already caps a single call at 300 KB and skips tagging past that — the cap starts doing its job, which is an argument that the guard was written for exactly this.
Source: bytedance/trae-agent