Skip to content

[BUG] rec_sys_personalized_with_trace() access an invalid key #198

@StefanoNoce

Description

@StefanoNoce

Required prerequisites

What version of camel-oasis are you using?

0.2.5

System information

installed via uv

3.11.14 (main, Dec 9 2025, 19:02:23) [Clang 21.1.4 ] linux

Problem description

in oasis/social_platform/recsys.py
in the function rec_sys_personalized_with_trace()

Image

'post_id' is not a valid key for trace -> raise an error

Reproducible example code

slightly modified version of
examples/experiment/twitter_simulation_1M_agents/twitter_simulation_1m.py
using twitter recsys

when calling
await platform.update_rec_table()

Traceback

Traceback (most recent call last):
  File "/home/noce/.local/share/uv/python/cpython-3.11.14-linux-x86_64-gnu/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/home/noce/.local/share/uv/python/cpython-3.11.14-linux-x86_64-gnu/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noce/.local/share/uv/python/cpython-3.11.14-linux-x86_64-gnu/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/noce/Documents/TG/backend/src/services/simulation_service.py", line 234, in run
    await self.platform.update_rec_table()
  File "/home/noce/Documents/TG/backend/.venv/lib/python3.11/site-packages/oasis/social_platform/platform.py", line 340, in update_rec_table
    new_rec_matrix = rec_sys_personalized_with_trace(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/noce/Documents/TG/backend/.venv/lib/python3.11/site-packages/oasis/social_platform/recsys.py", line 784, in rec_sys_personalized_with_trace
    swap_free_ids = [
                    ^
  File "/home/noce/Documents/TG/backend/.venv/lib/python3.11/site-packages/oasis/social_platform/recsys.py", line 786, in <listcomp>
    if post_id not in rec_post_ids and post_id not in [
                                                      ^
  File "/home/noce/Documents/TG/backend/.venv/lib/python3.11/site-packages/oasis/social_platform/recsys.py", line 787, in <listcomp>
    trace['post_id']
    ~~~~~^^^^^^^^^^^
KeyError: 'post_id'

Expected behavior

Not raising an error

Additional context

Image

trace only have these keys

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions