{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/diff-history-for-long-context-language-agents","title":"diff History for Neural Language Agents","arxiv_id":"2312.07540","date":"2023-12-12","proceeding":null,"authors":["Ulyana Piterbarg","Lerrel Pinto","Rob Fergus"],"abstract":"Neural Language Models (LMs) offer an exciting solution for general-purpose embodied control. However, a key technical issue arises when using an LM-based controller: environment observations must be converted to text, which coupled with history, results in long and verbose textual prompts. As a result, prior work in LM agents is limited to restricted domains with small observation size as well as minimal needs for interaction history or instruction tuning. In this paper, we introduce diff history, a simple and highly effective solution to these issues. By applying the Unix diff command on consecutive text observations in the interaction histories used to prompt LM policies, we can both abstract away redundant information and focus the content of textual inputs on the salient changes in the environment. On NetHack, an unsolved video game that requires long-horizon reasoning for decision-making, LMs tuned with diff history match state-of-the-art performance for neural agents while needing 1800x fewer training examples compared to prior work. Even on the simpler BabyAI-Text environment with concise text observations, we find that although diff history increases the length of prompts, the representation it provides offers a 25% improvement in the efficiency of low-sample instruction tuning. Further, we show that diff history scales favorably across different tuning dataset sizes. We open-source our code and data to https://diffhistory.github.io.","url_abs":"https://arxiv.org/abs/2312.07540v3","url_pdf":"https://arxiv.org/pdf/2312.07540v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"diff-history-for-long-context-language-agents","repo_url":"https://github.com/upiterbarg/diff_history","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"decision-making","task_name":"Decision Making"},{"task_slug":"nethack","task_name":"NetHack"},{"task_slug":"sequence-to-sequence-language-modeling","task_name":"Sequence-to-sequence Language Modeling"}],"methods":[{"method_slug":"focus","method_name":"Focus"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2312.07540","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2312.07540"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/upiterbarg/diff_history","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"unverified":3},"by_repo_kind":{"official":{"samples":7,"ran":4,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"b4edc5e72c592ef5","entry":"encode_cot_instruction_example","repo":"upiterbarg/diff_history","repo_kind":"official","path":"instruction_encode_templates.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/instruction_encode_templates.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b4edc5e72c592ef5"}},{"code_sha256_prefix":"661419d69a095bfe","entry":"encode_with_prompt_completion_format","repo":"upiterbarg/diff_history","repo_kind":"official","path":"finetune.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/finetune.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"661419d69a095bfe"}},{"code_sha256_prefix":"8657cb96e22ef006","entry":"form_prompt","repo":"upiterbarg/diff_history","repo_kind":"official","path":"nethack_experiments/format_interaction_histories.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/nethack_experiments/format_interaction_histories.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8657cb96e22ef006"}},{"code_sha256_prefix":"ac742238e5f3474d","entry":"get_samples","repo":"upiterbarg/diff_history","repo_kind":"official","path":"nethack_experiments/format_interaction_histories.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/nethack_experiments/format_interaction_histories.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ac742238e5f3474d"}},{"code_sha256_prefix":"96351a65183bb428","entry":"encode_few_shot_example","repo":"upiterbarg/diff_history","repo_kind":"official","path":"instruction_encode_templates.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/instruction_encode_templates.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"96351a65183bb428"}},{"code_sha256_prefix":"f839fd4c6f96a26f","entry":"encode_instruction_example","repo":"upiterbarg/diff_history","repo_kind":"official","path":"instruction_encode_templates.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/instruction_encode_templates.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f839fd4c6f96a26f"}},{"code_sha256_prefix":"93e1284e1779fc7d","entry":"encode_with_prompt_completion_format_observation_mask","repo":"upiterbarg/diff_history","repo_kind":"official","path":"finetune.py","file_url":"https://github.com/upiterbarg/diff_history/blob/HEAD/finetune.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"93e1284e1779fc7d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}