mirror of
https://github.com/GH05TCREW/pentestagent.git
synced 2026-03-07 14:23:20 +00:00
fix(tui): ensure workspace restores supersede manual target messages
This commit is contained in:
@@ -1678,6 +1678,12 @@ class PentestAgentTUI(App):
|
||||
self.agent.conversation_history.append(
|
||||
AgentMessage(role="system", content=f"Operator set target to {target}")
|
||||
)
|
||||
# Track manual target override so workspace restores can remove
|
||||
# or supersede this message when appropriate.
|
||||
try:
|
||||
setattr(self.agent, "_manual_target", target)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logging.getLogger(__name__).exception(
|
||||
"Failed to append target change to agent history: %s", e
|
||||
@@ -2020,6 +2026,28 @@ Be concise. Use the actual data from notes."""
|
||||
self.target = last
|
||||
if self.agent:
|
||||
self.agent.target = last
|
||||
# If the operator set a manual target while no
|
||||
# workspace was active, remove/supersede that
|
||||
# system message so the LLM uses the workspace
|
||||
# target instead of the stale manual one.
|
||||
try:
|
||||
manual = getattr(self.agent, "_manual_target", None)
|
||||
if manual:
|
||||
self.agent.conversation_history = [
|
||||
m
|
||||
for m in self.agent.conversation_history
|
||||
if not (
|
||||
m.role == "system"
|
||||
and isinstance(m.content, str)
|
||||
and m.content.strip().startswith("Operator set target to")
|
||||
)
|
||||
]
|
||||
try:
|
||||
delattr(self.agent, "_manual_target")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
from pentestagent.agents.base_agent import AgentMessage
|
||||
|
||||
|
||||
Reference in New Issue
Block a user