SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2504.03553 · ACL · 2025

Agentic Knowledgeable Self-awareness

Yong Jiang, Xiang Chen, Xiaobin Wang, Pengjun Xie, Fei Huang, Ningyu Zhang, Huajun Chen, Shuofei Qiao, Zhisong Qiu, Baochang Ren, Xiangyuan Ru

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2504.03553.json · badge: /api/ran/2504.03553.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
zjunlp/knowself marked official in Papers with Code
Papers with Code archive
4 ran · 3 no recorded run
FunctionStatusWhere it lives
GemmaTemplator Ran
ran on a synthesized input
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("a1b197616af86079")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List, Dict

# The class doesn't have an __init__, so INIT_ARGS is empty
INIT_ARGS = {}

# The computation method is `wrap`, which takes messages and optional kwargs
ARGS = {
    'messages': [
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'Hello, how are you?'},
        {'role': 'assistant', 'content': 'I am doing well, thank you!'},
        {'role': 'user', 'content': 'What is 2+2?'}
    ],
    'add_special_token_when_last_role_is_user': True,
    'add_end_splitter': False,
    'add_bos_token': True
}

METHOD = 'wrap'

# Setup and execution
if __name__ == '__main__':
    from typing import Optional, Dict, Sequence
    from typing import List, Tuple, Any, Dict
    import warnings

    class Templator:

        @classmethod
        def wrap(self, messages: List, **kwargs) -> str:
            raise NotImplementedError('Please implement the function `wrap` for the class Templator.')

        @classmethod
        def generate_structured_input(cls, messages: List[Dict], system_template: str, user_template: str, assistant_template: str, assistant_template_left: str, assistant_template_right: str, splitter: str, splitter_after_user: str=None, final_input: str=None, structured_final_input: List[str]=None, add_special_token_when_last_role_is_user: bool=True, add_end_splitter: bool=False) -> List[str]:
            if final_input == None:
                final_input = ''
            for message in messages:
                if message['role'] == 'system':
                    if system_template == None:
                        warnings.warn('The current templator is not supported the role `system`. Now we ignore the content in the system role.')
                    else:
                        final_input = f"{final_input}{system_template.format(prompt=message['content'])}{splitter}"
                elif message['role'] == 'user':
                    if splitter_after_user == None:
                        final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter}"
                    else:
                        final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter_after_user}"
                elif message['role'] == 'assistant':
                    final_input = f"{final_input}{assistant_template.format(prompt=message['content'])}{splitter}"
                else:
                    raise ValueError(f"the role `{message['role']}` is not supported. Our supported role list is `[system, user, assistant]`.")
            if add_end_splitter:
                final_input = f'{final_input}{splitter}'
            elif len(splitter) > 0:
                assert final_input.endswith(splitter)
                final_input = final_input[:-len(splitter)]
            if add_special_token_when_last_role_is_user and messages[-1]['role'] == 'user':
                final_input = f'{final_input}{splitter}'
            return final_input

    class GemmaTemplator(Templator):
        """<bos><start_of_turn>user
    user input 1<end_of_turn>
    <start_of_turn>model
    model output 1<end_of_turn>
    <start_of_turn>user
    user input 2<end_of_turn>
    <start_of_turn>model
    model output 2<end_of_turn>"""

        @classmethod
        def wrap(cls, messages: List, add_special_token_when_last_role_is_user: bool=False, add_end_splitter: bool=False, add_bos_token: bool=False) -> List[str]:
            default_system_prompt = None
            system_template = '<start_of_turn>system\n{prompt}<end_of_turn>'
            user_template = '<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model'
            assistant_template = '{prompt}<end_of_turn>'
            assistant_template_left = '<start_of_turn>model\n'
            assistant_template_right = '<end_of_turn>'
            splitter = '\n'
            if add_bos_token:
                final_input = '<bos>'
            else:
                final_input = ''
            return cls.generate_structured_input(messages=messages, system_template=system_template, user_template=user_template, assistant_template=assistant_template, assistant_template_left=assistant_template_left, assistant_template_right=assistant_template_right, splitter=splitter, final_input=final_input, add_special_token_when_last_role_is_user=add_special_token_when_last_role_is_user, add_end_splitter=add_end_splitter)

    # Construct and call
    instance = GemmaTemplator(**INIT_ARGS)
    result = getattr(instance, METHOD)(**ARGS)
    print("Result:")
    print(result)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Llama3Templator Ran
ran on a synthesized input
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("167e22a9b15461c1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from typing import List, Dict

# The Templator and Llama3Templator classes are defined above
# (copy-pasted from the problem statement)

from typing import Optional, Dict, Sequence
from typing import List, Tuple, Any, Dict
import warnings

class Templator:

    @classmethod
    def wrap(self, messages: List, **kwargs) -> str:
        raise NotImplementedError('Please implement the function `wrap` for the class Templator.')

    @classmethod
    def generate_structured_input(cls, messages: List[Dict], system_template: str, user_template: str, assistant_template: str, assistant_template_left: str, assistant_template_right: str, splitter: str, splitter_after_user: str=None, final_input: str=None, structured_final_input: List[str]=None, add_special_token_when_last_role_is_user: bool=True, add_end_splitter: bool=False) -> List[str]:
        if final_input == None:
            final_input = ''
        for message in messages:
            if message['role'] == 'system':
                if system_template == None:
                    warnings.warn('The current templator is not supported the role `system`. Now we ignore the content in the system role.')
                else:
                    final_input = f"{final_input}{system_template.format(prompt=message['content'])}{splitter}"
            elif message['role'] == 'user':
                if splitter_after_user == None:
                    final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter}"
                else:
                    final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter_after_user}"
            elif message['role'] == 'assistant':
                final_input = f"{final_input}{assistant_template.format(prompt=message['content'])}{splitter}"
            else:
                raise ValueError(f"the role `{message['role']}` is not supported. Our supported role list is `[system, user, assistant]`.")
        if add_end_splitter:
            final_input = f'{final_input}{splitter}'
        elif len(splitter) > 0:
            assert final_input.endswith(splitter)
            final_input = final_input[:-len(splitter)]
        if add_special_token_when_last_role_is_user and messages[-1]['role'] == 'user':
            final_input = f'{final_input}{splitter}'
        return final_input

class Llama3Templator(Templator):
    """<|begin_of_text|><|start_header_id|>user<|end_header_id|>

user input 1<|eot_id|><|start_header_id|>assistant<|end_header_id|>

model output 1<|eot_id|>"""

    @classmethod
    def wrap(cls, messages: List, add_special_token_when_last_role_is_user: bool=False, add_end_splitter: bool=False, add_bos_token: bool=False) -> List[str]:
        default_system_prompt = None
        system_template = '<|start_header_id|>system<|end_header_id|>\n\n{prompt}<|eot_id|>'
        user_template = '<|start_header_id|>user<|end_header_id|>\n\n{prompt}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n'
        assistant_template = '{prompt}<|eot_id|>'
        assistant_template_left = '<|start_header_id|>assistant<|end_header_id|>\n\n'
        assistant_template_right = '<|eot_id|>'
        splitter = ''
        if add_bos_token:
            final_input = '<|begin_of_text|>'
        else:
            final_input = ''
        return cls.generate_structured_input(messages=messages, system_template=system_template, user_template=user_template, assistant_template=assistant_template, assistant_template_left=assistant_template_left, assistant_template_right=assistant_template_right, final_input=final_input, splitter=splitter, add_special_token_when_last_role_is_user=add_special_token_when_last_role_is_user, add_end_splitter=add_end_splitter)


# Llama3Templator is a classmethod-only class with no __init__
# So INIT_ARGS is empty
INIT_ARGS = {}

# The computation method is wrap, which takes messages and optional kwargs
ARGS = {
    'messages': [
        {'role': 'user', 'content': 'Hello'},
        {'role': 'assistant', 'content': 'Hi there'}
    ],
    'add_special_token_when_last_role_is_user': False,
    'add_end_splitter': False,
    'add_bos_token': False
}

METHOD = 'wrap'

# Construct and call
instance = Llama3Templator()
result = getattr(instance, METHOD)(**ARGS)
print("Result:")
print(result)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Qwen2Templator Ran
ran on a synthesized input
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("8baed8907582a4a3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List, Dict

# The Qwen2Templator class doesn't have an __init__ method, so INIT_ARGS is empty
INIT_ARGS = {}

# The computation method is `wrap`, which takes messages and optional kwargs
ARGS = {
    'messages': [
        {'role': 'system', 'content': 'You are a helpful assistant.'},
        {'role': 'user', 'content': 'Hello, how are you?'},
        {'role': 'assistant', 'content': 'I am doing well, thank you for asking.'},
        {'role': 'user', 'content': 'What is 2+2?'}
    ],
    'add_special_token_when_last_role_is_user': False,
    'force_system_prompt': False,
    'add_end_splitter': False
}

METHOD = 'wrap'

# Construction and execution
if __name__ == '__main__':
    from typing import Optional, Dict, Sequence
    from typing import List, Tuple, Any, Dict
    import warnings

    class Templator:

        @classmethod
        def wrap(self, messages: List, **kwargs) -> str:
            raise NotImplementedError('Please implement the function `wrap` for the class Templator.')

        @classmethod
        def generate_structured_input(cls, messages: List[Dict], system_template: str, user_template: str, assistant_template: str, assistant_template_left: str, assistant_template_right: str, splitter: str, splitter_after_user: str=None, final_input: str=None, structured_final_input: List[str]=None, add_special_token_when_last_role_is_user: bool=True, add_end_splitter: bool=False) -> List[str]:
            if final_input == None:
                final_input = ''
            for message in messages:
                if message['role'] == 'system':
                    if system_template == None:
                        warnings.warn('The current templator is not supported the role `system`. Now we ignore the content in the system role.')
                    else:
                        final_input = f"{final_input}{system_template.format(prompt=message['content'])}{splitter}"
                elif message['role'] == 'user':
                    if splitter_after_user == None:
                        final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter}"
                    else:
                        final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter_after_user}"
                elif message['role'] == 'assistant':
                    final_input = f"{final_input}{assistant_template.format(prompt=message['content'])}{splitter}"
                else:
                    raise ValueError(f"the role `{message['role']}` is not supported. Our supported role list is `[system, user, assistant]`.")
            if add_end_splitter:
                final_input = f'{final_input}{splitter}'
            elif len(splitter) > 0:
                assert final_input.endswith(splitter)
                final_input = final_input[:-len(splitter)]
            if add_special_token_when_last_role_is_user and messages[-1]['role'] == 'user':
                final_input = f'{final_input}{splitter}'
            return final_input

    class Qwen2Templator(Templator):
        @classmethod
        def wrap(cls, messages: List[Dict], add_special_token_when_last_role_is_user: bool=False, force_system_prompt: bool=False, add_end_splitter: bool=False) -> str:
            default_system_prompt = 'You are a helpful assistant.'
            system_template = '<|im_start|>system\n{prompt}<|im_end|>'
            user_template = '<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant'
            assistant_template = '{prompt}<|im_end|>'
            assistant_template_left = '<|im_start|>assistant\n'
            assistant_template_right = '<|im_end|>'
            splitter = '\n'
            if force_system_prompt:
                is_existed = False
                for message in messages:
                    if message['role'] == 'system':
                        is_existed = True
                        break
                if is_existed == False:
                    messages = [{'role': 'system', 'content': default_system_prompt}] + messages
            return cls.generate_structured_input(messages=messages, system_template=system_template, user_template=user_template, assistant_template=assistant_template, assistant_template_left=assistant_template_left, assistant_template_right=assistant_template_right, splitter=splitter, add_special_token_when_last_role_is_user=add_special_token_when_last_role_is_user, add_end_splitter=add_end_splitter)

    # Construct and call
    instance = Qwen2Templator(**INIT_ARGS)
    result = getattr(instance, METHOD)(**ARGS)
    print("Result:")
    print(result)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
Templator Ran
ran on a synthesized input
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("091e063b8c292191")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import warnings
from typing import List, Dict

class Templator:

    @classmethod
    def wrap(cls, messages: List, **kwargs) -> str:
        raise NotImplementedError('Please implement the function `wrap` for the class Templator.')

    @classmethod
    def generate_structured_input(cls, messages: List[Dict], system_template: str, user_template: str, assistant_template: str, assistant_template_left: str, assistant_template_right: str, splitter: str, splitter_after_user: str=None, final_input: str=None, structured_final_input: List[str]=None, add_special_token_when_last_role_is_user: bool=True, add_end_splitter: bool=False) -> str:
        if final_input == None:
            final_input = ''
        for message in messages:
            if message['role'] == 'system':
                if system_template == None:
                    warnings.warn('The current templator is not supported the role `system`. Now we ignore the content in the system role.')
                else:
                    final_input = f"{final_input}{system_template.format(prompt=message['content'])}{splitter}"
            elif message['role'] == 'user':
                if splitter_after_user == None:
                    final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter}"
                else:
                    final_input = f"{final_input}{user_template.format(prompt=message['content'])}{splitter_after_user}"
            elif message['role'] == 'assistant':
                final_input = f"{final_input}{assistant_template.format(prompt=message['content'])}{splitter}"
            else:
                raise ValueError(f"the role `{message['role']}` is not supported. Our supported role list is `[system, user, assistant]`.")
        if add_end_splitter:
            final_input = f'{final_input}{splitter}'
        elif len(splitter) > 0:
            assert final_input.endswith(splitter)
            final_input = final_input[:-len(splitter)]
        if add_special_token_when_last_role_is_user and messages[-1]['role'] == 'user':
            final_input = f'{final_input}{splitter}'
        return final_input


INIT_ARGS = {}

ARGS = {
    'messages': [
        {'role': 'system', 'content': 'You are helpful.'},
        {'role': 'user', 'content': 'Hello'},
        {'role': 'assistant', 'content': 'Hi there!'},
        {'role': 'user', 'content': 'How are you?'}
    ],
    'system_template': '[SYSTEM]{prompt}[/SYSTEM]',
    'user_template': '[USER]{prompt}[/USER]',
    'assistant_template': '[ASSISTANT]{prompt}[/ASSISTANT]',
    'assistant_template_left': '[ASST_L]',
    'assistant_template_right': '[ASST_R]',
    'splitter': '\n',
    'splitter_after_user': None,
    'final_input': None,
    'structured_final_input': None,
    'add_special_token_when_last_role_is_user': True,
    'add_end_splitter': False
}

METHOD = 'generate_structured_input'

result = Templator.generate_structured_input(**ARGS)
print("Result:")
print(repr(result))
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
encode_with_messages_format Not yet run
unverified (harvested, no recorded run)
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("413afba62a8952fc")
How it ran

no invocation recorded.

main Not yet run
unverified (harvested, no recorded run)
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("5bbf3791e217df26")
How it ran

no invocation recorded.

parse_args Not yet run
unverified (harvested, no recorded run)
zjunlp/knowself/train/train_stage1.py
code served (permissive licence) · get_code("b1cc0d38e387f876")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Large Language Models (LLMs) have achieved considerable performance across various agentic planning tasks. However, traditional agent planning approaches adopt a "flood irrigation" methodology that indiscriminately injects gold trajectories, external feedback, and domain knowledge into agent models. This practice overlooks the fundamental human cognitive principle of situational self-awareness during decision-making-the ability to dynamically assess situational demands and strategically employ resources during decisionmaking. We propose agentic knowledgeable self-awareness to address this gap, a novel paradigm enabling LLM-based agents to autonomously regulate knowledge utilization. Specifically, we propose KnowSelf, a data-centric approach that applies agents with knowledgeable self-awareness like humans. Concretely, we devise a heuristic situation judgement criterion to mark special tokens on the agent's self-explored trajectories for collecting training data. Through a two-stage training process, the agent model can switch between different situations by generating specific special tokens, achieving optimal planning effects with minimal costs. Our experiments demonstrate that KnowSelf can outperform various strong baselines on different tasks and models with minimal use of external knowledge 1 .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2504.03553")
get_code_for_paper("2504.03553")
have("2504.03553")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2504.03553.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2504.03553.svg)](https://syntology.ai/paper/2504.03553)

Connect an agent — have() is free.