MCPcopy
hub / github.com/Fosowl/agenticSeek / push

Method push

sources/memory.py:158–173  ·  view source on GitHub ↗

Push a message to the memory.

(self, role: str, content: str)

Source from the content-addressed store, hash-verified

156 self.memory = memory
157
158 def push(self, role: str, content: str) -> int:
159 """Push a message to the memory."""
160 ideal_ctx = self.get_ideal_ctx(self.model_provider)
161 if ideal_ctx is not None:
162 if self.memory_compression and len(content) > ideal_ctx * 1.5:
163 self.logger.info(f"Compressing memory: Content {len(content)} > {ideal_ctx} model context.")
164 self.compress()
165 curr_idx = len(self.memory)
166 if self.memory[curr_idx-1]['content'] == content:
167 pretty_print("Warning: same message have been pushed twice to memory", color="error")
168 time_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
169 if config["MAIN"]["provider_name"] == "openrouter":
170 self.memory.append({'role': role, 'content': content})
171 else:
172 self.memory.append({'role': role, 'content': content, 'time': time_str, 'model_used': self.model_provider})
173 return curr_idx-1
174
175 def clear(self) -> None:
176 """Clear all memory except system prompt"""

Callers 15

memory.pyFile · 0.80
thinkMethod · 0.80
findInputsFunction · 0.80
processMethod · 0.80
processMethod · 0.80
sync_llm_requestMethod · 0.80
execute_modulesMethod · 0.80
processMethod · 0.80
make_planMethod · 0.80
processMethod · 0.80
llm_decideMethod · 0.80
processMethod · 0.80

Calls 4

get_ideal_ctxMethod · 0.95
compressMethod · 0.95
pretty_printFunction · 0.90
infoMethod · 0.80

Tested by 6

test_pushMethod · 0.64
test_clearMethod · 0.64
test_clear_sectionMethod · 0.64
test_getMethod · 0.64
test_resetMethod · 0.64